Skip to content

Instantly share code, notes, and snippets.

View WooodHead's full-sized avatar

WooodHead

  • Hangzhou
View GitHub Profile
@nkmdk-007
nkmdk-007 / createOutline.js
Created March 13, 2014 16:13
This one popped up in the Chrome debugger, saving and referring to these is a good way to learn how vendors implement their JS code and we can learn from any patterns used.
/**
* This code contains an implementation of HTML5 outlining algorithm, as described by WHATWG at [1]
*
* The copyright notice at [2] says:
* (c) Copyright 2004-2009 Apple Computer, Inc., Mozilla Foundation, and Opera Software ASA.
* You are granted a license to use, reproduce and create derivative works of this document.
*
* [1] http://www.whatwg.org/specs/web-apps/current-work/multipage/sections.html#outlines
* [2] http://www.whatwg.org/specs/web-apps/current-work/multipage/index.html
*/
@juanem1
juanem1 / mongoimport-export.txt
Last active July 16, 2017 08:02
mongoimport / mongoexport MongoDB
mongoimport
-h [ --host ] arg mongo host to connect to ( <set name>/s1,s2 for sets)
-u [ --username ] arg username
-p [ --password ] arg password
-d [ --db ] arg database to use
-c [ --collection ] arg collection to use (some commands)
-f [ --fields ] arg comma separated list of field names e.g. -f name,age
--file arg file to import from; if not specified stdin is used
--drop drop collection first
--upsert insert or update objects that already exist
@chrislopresto
chrislopresto / tomorrow.style
Created August 2, 2016 04:15
MWeb Tomorrow Preview CSS Theme
editor
foreground: cccccc
background: 2d2d2d
caret: cc99cc
editor-selection
foreground: ffffff
background: 515151
H1
@boriscy
boriscy / incomes_controller.rb
Last active October 14, 2017 08:05
Print to PDF using phantomjs
# Example controller
class IncomesController < ApplicationController
# Include the print
include Controllers::Print
# GET /incomes/1
def show
@income = present Income.find(params[:id])
respond_to do |format|
@falkben
falkben / url_scrape.py
Last active November 4, 2017 03:23
scrapes a website for all the URLs below it
''' scrapes a website for urls '''
import requests
from bs4 import BeautifulSoup
class URLTest():
def __init__(self, link, status_code, current_depth, head):
self.link = link
self.status_code = status_code
@apocas
apocas / gist:4583334
Last active November 26, 2017 12:05
Node NPM registry crawler.
var jsdom = require('jsdom'),
request = require('request'),
url = require('url'),
npm = require("npm"),
redis = require("redis");
var client = redis.createClient();
var configObject = {
"dev": false,
@WooodHead
WooodHead / crawler.js
Created November 26, 2017 12:35 — forked from kyrcha/crawler.js
npm registry crawler
var request = require('request'),
cheerio = require('cheerio'),
async = require('async');
var base = 'https://www.npmjs.org',
concurrency = 2;
var q = async.queue(function(task, next) {
setTimeout(function() {
console.log('GET ' + task.url);
@mallamanis
mallamanis / gettopprojects.py
Last active December 22, 2017 15:35
Get top projects from GHTorrent
#!/usr/bin/python
import csv, sys, os
import numpy as np
# Get the top X non-fork projects for the GHTorrent dump (without using SQL)
# The dumps should be available at http://ghtorrent.org/downloads.html
if len(sys.argv) < 5:
print "Usage <dir> <language> <topX> <outcsv>"
sys.exit(-1)
@mrmoneyc
mrmoneyc / my.cnf
Created August 14, 2011 06:06
my.cnf
[client]
socket = /tmp/mysql.sock
default-character-set = utf8
[mysqld]
socket = /tmp/mysql.sock
datadir = /usr/local/mysql/data
/**
* Created by shahartaite on 23/11/2016.
*/
import consts from 'js/consts';
export const allLeftNavSelectedFiltersSelector = (state) => state[consts.TOP_LEVEL_STATE_REDUCERS.FILTERING_THING_CAPABILITIES_REDUCER].get(consts.STATE_INNER_OBJECT_NAMES.LEFT_NAV_SELECTED_FILTER_PATHS).toJS();
export const selectedSearchBarTermSelector = (state) => {
return state[consts.TOP_LEVEL_STATE_REDUCERS.FILTERING_THING_CAPABILITIES_REDUCER].get(consts.STATE_INNER_OBJECT_NAMES.SEARCH_BAR_TERM).toJS();
}
export const graphStartTimeSelector = (state) => state[consts.TOP_LEVEL_STATE_REDUCERS.FILTERING_THING_CAPABILITIES_REDUCER].get(consts.STATE_INNER_OBJECT_NAMES.SELECTED_START_TIME_FOR_GRAPHS);