Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile
@andreagrandi
andreagrandi / parse_json_post.go
Created August 19, 2014 13:28
Parse a JSON http POST in GoLang
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type test_struct struct {
Test string
@sebmarkbage
sebmarkbage / react_legacyfactory.md
Last active March 23, 2026 03:02
Use a factory or JSX

React Element Factories and JSX

You probably came here because your code is calling your component as a plain function call. This is now deprecated:

var MyComponent = require('MyComponent');

function render() {
 return MyComponent({ foo: 'bar' }); // WARNING
@john2x
john2x / 00_destructuring.md
Last active April 25, 2026 03:06
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@bsag
bsag / .vimrc
Last active October 20, 2018 21:13
My vim and tmux configs, using airline (as discussed [here](http://www.rousette.org.uk/blog/archives/tinkering-with-vim/). The Powerline theme is pretty much the default (may be a bit old now) and I just commented out a few plugins I didn't need. I use the patched Sauce Code Pro for my powerline/airline font.
" Set up Vundle to manage plugins
set nocompatible
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
@staltz
staltz / introrx.md
Last active July 24, 2026 00:55
The introduction to Reactive Programming you've been missing
@emad-elsaid
emad-elsaid / uk_top_40_singles_chart.rb
Created April 30, 2014 14:36
Scrap UK top 40 singles chart from BBC this is small but useful script, it could be used as a plugin for sublimeText, CMS, news website to get the top 40 UK singles from BBC website. script gets teh printable format of the chart and extract data then form them as array of Hash maps easy to iterate on and filter the original full chart is here : h…
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
# it turns out that BBC website has a printable version of
# the top 40 UK singles chart, that made me jump of joy :D
require 'open-uri'
# get BBC singles chart printable version
page = open('http://www.bbc.co.uk/radio1/chart/singles/print').read
# result has data as table so we'll extract keys from TH tags
@lfender6445
lfender6445 / gist:9919357
Last active June 4, 2026 13:42
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@crimeminister
crimeminister / security.js
Created March 20, 2014 19:58
Express middleware for IP-based access control
'use strict';
var _ = require('lodash');
var keystone = require('keystone');
var range_check = require('range_check');
var util = require('util');
/**
*
*/
@umidjons
umidjons / sort-object-properties-by-value.md
Last active June 9, 2026 18:21
JavaScript: sort object properties by value (numeric or string)

Sort object properties by value (values are text)

I have following object:

var cities={10:'Tashkent', 14:'Karakalpakiya', 16:'Andijan'};

I want sort it by city names, so after sort it should be:

var cities={16:'Andijan', 14:'Karakalpakiya', 10:'Tashkent'};

But I can't sort object properties, instead can convert object into array, then sort items.

@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #