Skip to content

Instantly share code, notes, and snippets.

@maxijonson
maxijonson / post-commit
Created March 16, 2019 20:27
git post-commit hook to work with Heroku, Github and sensitive files
#!/bin/sh
# After each commit on master (Heroku), it will switch to the Github branch and cherry-pick that commit into it. Then, switch back to master.
# This makes the committing flow seamless so all you have to do is push (which is safer done manually than with a hook)
# IMPORTANT: ANY changes in sensitive files should be commited alone (without public changes) or the sensitive files will be cherry picked in the public branch
# To skip this cherry-picking procedure (when you add a sensitive commit), start the commit message with "NCP" e.g.: "NCP Add some secret stuff"
ERR='\e[31m'
SUCCESS='\e[32m'
WARN='\e[33m'
@MightyPork
MightyPork / ansi_rgb.js
Last active October 4, 2023 08:55
Convert ANSI color 0-255 to RGB
const low_rgb = [
'#000000', '#800000', '#008000', '#808000', '#000080', '#800080', '#008080', '#c0c0c0',
'#808080', '#ff0000', '#00ff00', '#ffff00', '#0000ff', '#ff00ff', '#00ffff', '#ffffff'
]
function ansi_rgb(ansi) {
if (ansi < 0 || ansi > 255) return '#000'
if (ansi < 16) return low_rgb[ansi]
if (ansi > 231) {
@gbaman
gbaman / HowToOTGFast.md
Last active May 14, 2024 10:26
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

@Restuta
Restuta / framework-sizes.md
Last active March 7, 2024 00:01
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@jshcrowthe
jshcrowthe / fibonacci.js
Created May 14, 2015 01:58
Fibonacci Sequence (The cool way)
var fibonacci = function(n) {
return Array.apply(null, Array(n))
.reduce(function(sequence, value, index) {
return sequence.concat((index < 2) ? index : sequence[index - 1] + sequence[index - 2]);
}, []);
};
var defaults = {
number: 1,
bool: true,
magic: 'real',
animal: 'whale',
croutons: 'delicious'
};
var options = {
number: 2,
@dmiddlecamp
dmiddlecamp / emailDemo.cpp
Created February 11, 2014 20:04
A pretty rough example for sending an emil!
#define SMTP_SERVER "smtp.yourserver.com"
#define SMTP_USER_BASE64 "base64_encode_your_user"
#define SMTP_PASS_BASE64 "base64_encode_your_pass"
#define SMTP_FROM_EMAIL "email@from.com"
#define SMTP_TO_EMAIL "email@to.com"
#define SMTP_SUBJECT "Email from a Core!"
#define SMTP_BODY "Body body body"
#include "application.h"
@pbrisbin
pbrisbin / install.md
Last active August 25, 2021 14:06
Installing OpenCart on Heroku

Installation

This gets OpenCart running enough that we can use the GUI Installer

  1. Create Heroku project with ClearDB MySQL add-on
  2. Download OpenCart sources
  3. Move ./upload/* to top-level (those are the PHP site files)
  4. Copy zlib.so into ./ext/zlib.so
  5. Write extension = /app/www/ext/zlib.so into php.ini
  6. Push
@iznax
iznax / Readme.md
Created February 23, 2012 04:24
Mini Tetris in less than 140 bytes

Mini Tetris

A slightly more well-behaved version of Tetris than some other 140 byte projects. The left and right sides of the screen block player movement. The game view is larger and the width and height of the screen are included as constants you can manipulate.

Play 140-character Version

I made a more accurate version of the game with proper all the rotating pieces. This of course is larger and the core logic takes 256 characters.

Play Full Version

@zachharkey
zachharkey / CSSToggle.py
Created February 12, 2012 03:05
SublimeText2 Module Toggle CSS format between single and multiline
import sublime, sublime_plugin, re
DEBUG_ENABLED = False
PRINT_CONTEXT = False
# Toggle between single-line or multi-line formatted css statement
#
# Add the following line to Preferences > Key Bindings - User
# { "keys": ["ctrl+shift+j"], "command": "toggle_single_line_css" }
#