Skip to content

Instantly share code, notes, and snippets.

@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@lancejpollard
lancejpollard / node-folder-structure-options.md
Created November 28, 2011 01:50
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@weierophinney
weierophinney / GuestModule.php
Created December 5, 2011 22:34
Example listener for changing layouts
<?php
namespace Guest;
use Zend\EventManager\StaticEventManager;
class Module
{
public function init()
{
$events = StaticEventManager::getInstance();
@cpudney
cpudney / eastersunday.js
Created March 30, 2012 07:11
Easter Sunday
const FIRST_YEAR = 325;
const LAST_YEAR = 3000;
const WIDTH = 960;
const HEIGHT = 500;
const INSETS = {'left': 40,
'right': 10,
'top': 10,
'bottom': 60};
@alattis
alattis / gist:4371327
Last active December 10, 2015 02:58
pretty logging when added to the prefix header, logs nothing when the OPTIMIZE build flag is present
#ifndef __OPTIMIZE__
# define NSLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
# define NSLog(...) {}
#endif
// Debugビルド時のみNSLogを出力する
#ifdef DEBUG
#define DebugNSLog(...); NSLog(__VA_ARGS__);
#else
#define DebugNSLog(...); // NSLog(__VA_ARGS__);
#endif
@vsajip
vsajip / pyvenvex.py
Last active June 18, 2024 21:25
A script which demonstrates how to extend Python 3.3's EnvBuilder, by installing setuptools and pip in created venvs. This functionality is not provided as an integral part of Python 3.3 because, while setuptools and pip are very popular, they are third-party packages.The script needs Python 3.3 or later; invoke it using"python pyvenvex.py -h"fo…
#
# Copyright (C) 2013-2020 Vinay Sajip. New BSD License.
#
import os
import os.path
from subprocess import Popen, PIPE
import sys
from threading import Thread
from urllib.parse import urlparse
from urllib.request import urlretrieve
@igor-shevchenko
igor-shevchenko / textrank.py
Created June 20, 2013 08:34
TextRank algorithm for text summarization.
from itertools import combinations
from nltk.tokenize import sent_tokenize, RegexpTokenizer
from nltk.stem.snowball import RussianStemmer
import networkx as nx
def similarity(s1, s2):
if not len(s1) or not len(s2):
return 0.0
return len(s1.intersection(s2))/(1.0 * (len(s1) + len(s2)))
#!/bin/sh
#
# Example script to start up tunnel with autossh.
#
# This script will tunnel 12345 from the remote host
# to 12345 on the local host.
#
ID=login_here
HOST=destination.host.com
if [ "X$SSH_AUTH_SOCK" = "X" ]; then
@bonty
bonty / DisableNSLogOnReleaseBuild.h
Created August 6, 2013 11:13
ReleaseビルドでNSLog()を無効にする
#ifdef NS_BLOCK_ASSERTIONS
#ifndef NSLog
// NSLogを無効にする
#define NSLog( m, args... )
#endif
#else
#ifndef NSLog