Skip to content

Instantly share code, notes, and snippets.

Motivation Machine

Motivation is spread all over the internet. Sometimes it does not reach the right people. Sometimes it does not reach at the right time.

Motivation Machine is an app ( or series of apps ) that will try to collect motivational posts, pictures etc. from the right sources and deliver them to people.

All the app(s) are going to be open sourced and all the contents that are shared inside the app will be accompanied by a hyperlink to where it originated.

Overview

image

@scriptnull
scriptnull / donate_transactions.md
Last active June 4, 2017 17:42
A public log of my donations to things I believe in.
@scriptnull
scriptnull / redis_connection.go
Last active August 17, 2017 19:03
Initialize a redis connection via github.com/garyburd/redigo/redis
// Uses github.com/garyburd/redigo/redis Go Library
log.Println("Initializing Redis Message Queue")
conn, err := redis.Dial("tcp", fmt.Sprintf("%s:%s", os.Getenv("REDIS_HOSTNAME"), os.Getenv("REDIS_PORT")))
if err != nil {
log.Fatalln("Failed to initialize redis message queue", err)
}
defer conn.Close()
log.Println("Initialized Redis Message Queue successfully")
@scriptnull
scriptnull / redis_queue.go
Created August 17, 2017 19:03
Do redis queue operations with github.com/garyburd/redigo/redis
// Uses github.com/garyburd/redigo/redis Go Library
// push to queue
_, err := conn.Do("LPUSH", "badge:worker", []byte("some data"))
// Blocking pop from queue
payload, err := redis.Strings(redisConn.Do("BRPOP", "badge:worker", 0))
if err != nil {
log.Fatalln("Failed to do blocking RPOP on badge:worker", err)
}
remote := "https://github.com/scriptnull/scribble"
jsonPayload := "{}" // assume some dummy data
redisConn.Send("MULTI")
// add to a set
redisConn.Send("SADD", "badgeit:queuedRemotes", remote)
// push to queue
redisConn.Send("LPUSH", "badge:worker", []byte(jsonPayload))
_, err = redisConn.Do("EXEC")
@scriptnull
scriptnull / binary_preorder_traversal_recursive.go
Created October 28, 2017 11:21
Pre order Traversal in binary tree
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func preorderTraversal(root *TreeNode) []int {
var result []int
@scriptnull
scriptnull / binary_preorder_traversal_iterative.java
Created October 28, 2017 12:03
Pre order Traversal in binary tree using an iterative approach.
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
@scriptnull
scriptnull / binary_inorder_traversal_recursive.go
Created October 28, 2017 12:26
Inorder Traversal in binary tree.
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func inorderTraversal(root *TreeNode) []int {
var result []int
@scriptnull
scriptnull / binary_inorder_traversal_iterative.java
Created October 29, 2017 07:59
Binary tree inorder traversal using a iterative approach with help of a stack.
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
@scriptnull
scriptnull / binary_inorder_traversal_morris.java
Last active October 29, 2017 11:05
Binary Tree inorder traversal iterative approach, without using stacks and using morris traversal.
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func inorderTraversal(root *TreeNode) []int {
var result []int