Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile
@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
@jhenly
jhenly / hosts
Last active January 29, 2016 14:24
/etc/hosts - An ongoing list of ad/stupid sites to block traffic from.
# /etc/hosts
127.0.0.1 localhost
# Block traffic from these ad sites:
#+ doubleclick domains
0.0.0.0 doubleclick.net
0.0.0.0 www.doubleclick.net
0.0.0.0 cm.g.doubleclick.net
0.0.0.0 www.cm.g.doubleclick.net
upstream php {
server unix:/var/run/php5-fpm.sock;
}
server {
# enforce NO www
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
@kevgathuku
kevgathuku / docker-cleanup.sh
Created February 17, 2015 22:16
Remove docker temporary built images
#!/bin/bash
# Source: http://blog.stefanxo.com/2014/02/clean-up-after-docker/
docker images -f dangling=true -q | xargs -r docker rmi -f #Adding -f forces removal
@goizueta
goizueta / getPastPrsForUser.js
Last active June 13, 2016 16:22
Get past PRs. Github API only goes back 300 events (comments, commits, pushes, pulls, etc...)
var GitHubApi = require("github");
var user = "kn9ts";
var pullRequests = [];
var github = new GitHubApi({
// optional
debug: false,
protocol: "https",
host: "api.github.com", // should be api.github.com for GitHub
pathPrefix: "", // for some GHEs; none for GitHub
timeout: 5000,
@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');
/**
*
*/
<br /><br />
# React Native: Animated
ReactEurope 2015, Paris - Spencer Ahrens - Facebook
<br /><br />
## Fluid Interactions
- People expect smooth, delightful experiences
@sagar-ganatra
sagar-ganatra / WrapRenderFunction.js
Created January 25, 2013 05:52
Adding beforeRender and afterRender functions to a Backbone View Refer to the blog post http://www.sagarganatra.com/2013/01/adding-beforerender-and-afterrender-functions-to-backbone-view.html
(function () {
var TestView = Backbone.View.extend({
el: '#container',
initialize: function () {
console.log('Inside Init');
@fengmk2
fengmk2 / mongoskin-demo.js
Created September 5, 2011 11:29
mongoskin CRUD demo
var mongo = require('mongoskin');
var db = mongo.db('127.0.0.1:27017/test');
// create index:
// key, unique, callback
db.collection('user').ensureIndex([['name', 1]], true, function(err, replies){});
// bind method: db.user ===> db.collection('user')
db.bind('user');
@azat-co
azat-co / express.js
Last active August 19, 2018 03:30
Tutorial: REST API with Node.js and MongoDB using Mongoskin and Express.js
var express = require('express')
, mongoskin = require('mongoskin')
var app = express()
app.use(express.bodyParser())
var db = mongoskin.db('localhost:27017/test', {safe:true});
app.param('collectionName', function(req, res, next, collectionName){
req.collection = db.collection(collectionName)