Skip to content

Instantly share code, notes, and snippets.

View SathinduGA's full-sized avatar
💭
Eat | Sleep | Code

Sathindu SathinduGA

💭
Eat | Sleep | Code
View GitHub Profile
@SathinduGA
SathinduGA / scheduler.py
Last active March 24, 2020 19:55
Heroku Python Script
import datetime
import pymongo
client = pymongo.MongoClient("mongodb://<user>:<password>@<host>:<port>/<db_namespace>")
def save_data_to_mongo(data):
db = client["<db_namespace>"]
collection = db["test_data"]
response = collection.insert_one(data)
@SathinduGA
SathinduGA / DBOperations.java
Created September 22, 2019 08:13
Sample JDBC Database Connection
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package testui;
//Import required packages
import java.sql.*;
@SathinduGA
SathinduGA / rnredux_file_structure
Created September 9, 2018 16:48
File Structure
src
|_components
| |_counter.js
|
|_screens
| |_main_screen.js
|
|_store
|_actions
| |_action_types.js
@SathinduGA
SathinduGA / rnredux_main_screen.js
Last active September 10, 2018 15:09
Main Screen
import React, { Component } from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { connect } from 'react-redux';
import { counterAdd, counterSubtract } from '../store/actions/index';
import CounterComponent from '../components/counter';
class MainScreen extends Component {
@SathinduGA
SathinduGA / rnredux_component_counter.js
Last active September 10, 2018 11:47
Counter Component
import React, { Component } from "react";
import { View, Text, StyleSheet } from "react-native";
import { connect } from "react-redux";
class CounterComponent extends Component {
constructor(props) {
super(props);
this.state = {};
}
@SathinduGA
SathinduGA / rnredux_actions_index.js
Last active September 10, 2018 15:10
Actions Index
export { counterAdd, counterSubtract } from './counter_actions';
import { COUNTER_ADD, COUNTER_SUBTRACT } from "./action_types";
export const counterAdd = () => {
return {
type: COUNTER_ADD
};
}
export const counterSubtract = () => {
return {
@SathinduGA
SathinduGA / rnredux_action_types.js
Last active September 10, 2018 15:12
Action Types
export const COUNTER_ADD = 'COUNTER_ADD';
export const COUNTER_SUBTRACT = 'COUNTER_SUBTRACT';
import React from 'react'; // Remember to import React
import { AppRegistry } from 'react-native';
import { Provider } from 'react-redux';
import {name as appname} from './app.json';
import Application from './src/app';
import configStore from './src/store/config_store';
const store = configStore();
import { createStore, combineReducers } from 'redux';
import counterReducer from './reducers/counter_reducer';
const rootReducer = combineReducers({
counter: counterReducer,
});
const configStore = () => {
return createStore(rootReducer);
};