Skip to content

Instantly share code, notes, and snippets.

View jgcmarins's full-sized avatar

João Marins jgcmarins

View GitHub Profile
@jed
jed / LICENSE.txt
Created May 20, 2011 19:57 — forked from 140bytes/LICENSE.txt
convert HEX to RGB
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@solenoid
solenoid / gist:1372386
Created November 17, 2011 04:49
javascript ObjectId generator
var mongoObjectId = function () {
var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
return (Math.random() * 16 | 0).toString(16);
}).toLowerCase();
};
@femto113
femto113 / transpose.js
Last active September 6, 2023 00:28
one line transpose for 2-dimensional Javascript arrays
function transpose(a)
{
return a[0].map(function (_, c) { return a.map(function (r) { return r[c]; }); });
// or in more modern dialect
// return a[0].map((_, c) => a.map(r => r[c]));
}
@timoxley
timoxley / drop_collections.js
Created July 27, 2012 17:30
mongoose drop collections helper
var async = require('async')
var _ = require('underscore')
var Helpers = function(mongoose) {
this.mongoose = mongoose || require('mongoose')
this.dropCollections = function(callback) {
var collections = _.keys(mongoose.connection.collections)
async.forEach(collections, function(collectionName, done) {
var collection = mongoose.connection.collections[collectionName]
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@banaslee
banaslee / XGH - de-de.txt
Last active March 25, 2025 12:53
eXtreme Go-Horse Process
eXtreme Go Horse (XGH) Process
Quelle: http://gohorseprocess.wordpress.com
Übersetzung ursprünglich von https://gist.github.com/Neffez/f8d907ba8289f14e23f3855011fa4e2f
1. Ich denke, also ist es nicht XGH.
In XGH wird nicht gedacht, es wird das erste gemacht, was in den Sinn kommt. Es gibt auch keine zweite Option, die erste ist schneller.
2. Es gibt 3 Wege ein Problem zu lösen: den richtigen Weg, den falschen Weg und den XGH Weg, welcher exakt wie der falsche ist, aber schneller.
@renancouto
renancouto / color.lighten.js
Created January 30, 2013 17:58
Method to lighten / darken hex colors using Javascript.
var LightenColor = function(color, percent) {
var num = parseInt(color,16),
amt = Math.round(2.55 * percent),
R = (num >> 16) + amt,
B = (num >> 8 & 0x00FF) + amt,
G = (num & 0x0000FF) + amt;
return (0x1000000 + (R<255?R<1?0:R:255)*0x10000 + (B<255?B<1?0:B:255)*0x100 + (G<255?G<1?0:G:255)).toString(16).slice(1);
};
@jstejada
jstejada / kmeans.py
Last active September 19, 2018 19:49
Intento de k-means para segmentación de imágenes
'''
Created on Mar 17, 2013
@author: JuanTejada
'''
from math import sqrt
from operator import div
import Image
import random
import sys
@grenade
grenade / 01-generate-ed25519-ssh-key.sh
Last active March 30, 2025 00:27
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
#!/bin/bash
mkdir -p ~/.ssh
# generate new personal ed25519 ssh keys
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <[email protected]>"
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_robtn -C "rob thijssen <[email protected]>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
@plentz
plentz / nginx.conf
Last active March 28, 2025 17:48
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048