Skip to content

Instantly share code, notes, and snippets.

View ryanhanwu's full-sized avatar
🎯
Focusing

Ryan Wu ryanhanwu

🎯
Focusing
View GitHub Profile
@lawrencejones
lawrencejones / agg.coffee
Last active March 15, 2019 19:00
Projection generator for mongodb
_ = require 'underscore'
# Given an array of elements ELEM and a matching KEY value,
# will build the apprpriate projection to generate sortable
# weights for a mongo aggregator.
#
# ELEM: An array of values upon which to match against KEY
# KEY: The document field key to match against
# I: Default 0, index into array at which to begin
#
@joshuapowell
joshuapowell / reset.less
Last active December 12, 2021 13:35
LESS: Global LESS CSS reset that gives elements default formatting.
/**
* Global Reset of all HTML Elements
*
* Resetting all of our HTML Elements ensures a smoother
* visual transition between browsers. If you don't believe me,
* try temporarily commenting out this block of code, then go
* and look at Mozilla versus Safari, both good browsers with
* a good implementation of CSS. The thing is, all browser CSS
* defaults are different and at the end of the day if visual
* consistency is what we're shooting for, then we need to
@cbdavide
cbdavide / BinarySearch.js
Last active April 30, 2022 02:18
Binary search algorithm in javascript
var binarySearch = function(array, value) {
var guess,
min = 0,
max = array.length - 1;
while(min <= max){
guess = Math.floor((min + max) /2);
if(array[guess] === value)
return guess;
else if(array[guess] < value)
-- Author: Michael Bianco <http://mabblog.com/>
-- Some help from: http://discussions.info.apple.com/message.jspa?messageID=10363317
on create_vpn_service(vpn_name)
tell application "System Preferences"
reveal pane "com.apple.preference.network"
activate
tell application "System Events"
tell process "System Preferences"
# A little Meteor CheatSheet about Iron-Router. (updated on a weekly basis)
# Check our Studio: https://gentlenode.com/
meteor add iron:router
meteor update iron:router
# Iron Router > Configuration
@fiee
fiee / laenderinfos.sql
Last active July 17, 2023 14:04
table of information about all countries of the world (German names)
CREATE TABLE adressen.land
(
isocode_2 character(2) not null, -- ISO 3166 ALPHA-2
isocode_3 character(3) not null, -- ISO 3166 ALPHA-3
name character varying not null, -- deutscher Name des Landes (international besser via ISO-Code ankoppeln!) // German name of the country
vorwahl integer default null, -- internationale Vorwahl // international phone code
null_bei_vorwahl boolean default FALSE, -- muss man die Null der Ortsvorwahl auch nach der internationalen Vorwahl wählen? // must one dial zero between international and local phone code?
vorwahl_lokal boolean default FALSE, -- muss man vor Ort die Vorwahl wählen? // must one dial the local phone code also locally?
tld character varying default NULL, -- Top Level Domain
kfz character varying default NULL, -- KFZ-Kennzeichen // car code
@callumacrae
callumacrae / build-tools.md
Last active October 25, 2023 15:14
Build tools written in JavaScript
@jessedearing
jessedearing / gist:2351836
Created April 10, 2012 14:44 — forked from twoism-dev/gist:1183437
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
@aheckmann
aheckmann / storeImgInMongoWithMongoose.js
Created April 17, 2012 19:14
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
@othiym23
othiym23 / npm-upgrade-bleeding.sh
Created September 20, 2014 19:36
a safe way to upgrade all of your globally-installed npm packages
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done