Skip to content

Instantly share code, notes, and snippets.

View therealtakeshi's full-sized avatar

Takeshi Takahashi therealtakeshi

View GitHub Profile
@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
@turtlesoupy
turtlesoupy / nginx.conf
Created July 8, 2012 21:16
node.js upstream nginx config
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
@AvnerCohen
AvnerCohen / npm-cheat-sheet.md
Last active July 9, 2023 09:14
Node.js - npm Cheat Sheet

Node.js - npm Cheat Sheet

(Full description and list of commands at - https://npmjs.org/doc/index.html)

List of less common (however useful) NPM commands

Prepand ./bin to your $PATH

Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:

@ufologist
ufologist / CryptoJS-DES.html
Created May 15, 2013 03:34
Use CryptoJS encrypt message by DES and direct decrypt ciphertext, compatible with Java Cipher.getInstance("DES")
<!-- test pass with CryptoJS v3.1.2 -->
<script src="rollups/tripledes.js"></script>
<script src="components/mode-ecb.js"></script>
<script>
/**
* Encrypt message by DES in ECB mode and Pkcs7 padding scheme
*
* NOTE: DES is weak, please use 3DES(Triple DES) or AES
*
* @param {String} message

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

#!/bin/bash
# This script assumes you have an app running on 2 ports 4040 and 4041
# and that you can restart your app with a single command
APP_RESTART_COMMAND="/your/app/control restart"
# Find out if the app is running
function app_up {
port=$1
@mynameisfiber
mynameisfiber / neighborhoods.json
Created August 13, 2014 15:16
Centroids for neighborhoods in Manhattan
[
{
"name": "Lower East Side",
"center": [
-73.9836180698,
40.7155233255
]
},
{
"name": "Marble Hill",

These examples are presented in an attempt to show how each coding styles attempts to or does not attempt to isolate side-effects. There are only 2 semantic elements in a barebone "Hello World" implementation:

  • Invocation of console.log
  • Declaration of HELLO_WORLD

Since every coding style can abstract away data into a parameter or variable, there is no point for us to show that. All implementations assume HELLO_WORLD is a constant that is always inlined. This way it reduces the variations we need to present. (To make an anology, if we were to implement incrementByOne, would we need to inline the number 1 or pass it in as parameter?)

CAVEAT/LIMITATION: All implementations also assume console is static global. In case of functional programming, console.log is asumed to be a function that can be passed around without further modification. (This is not the case in the browser, but that can be resolved with console.log.bind(console))

Declarative

@LotteMakesStuff
LotteMakesStuff / TrafficLightAttribute.cs
Last active February 2, 2024 15:58
TrafficLight control/layout/property drawer: Adds a new editor control that draws lil Traffic Lights in the inspector. its really useful for visualizing state. For example, checkboxes can be hard to read at a glace, but a Red or Green status light is easy! Recommend you use the attached package, as it has all the icon image files.
// Non Editor code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class TrafficLightAttribute : PropertyAttribute
{
public bool DrawLabel = true;
public string CustomLabel;
public bool AlsoDrawDefault;