Skip to content

Instantly share code, notes, and snippets.

View gogson's full-sized avatar
🚧
Working on Griffoner.com

Hugo Lafitte gogson

🚧
Working on Griffoner.com
View GitHub Profile
@SylTi
SylTi / promiseTimeout.js
Created December 17, 2018 17:25
javascript promise timeout using await
const promiseTimeout = function(ms, promise){
// Create a promise that rejects in <ms> milliseconds
let timeout = new Promise((resolve, reject) => {
let id = setTimeout(() => {
clearTimeout(id);
reject('Timed out in '+ ms + 'ms.')
}, ms)
})
@gogson
gogson / docker-bash-command.md
Last active October 3, 2023 15:17
Open a bash to a running Docker container using a shell command

Purpose

Create a bash command for opening a shell to a running Docker container

Usage

Fetch container ID from docker ps and run docker-bash 880e6a9d9601 where "880e6a9d9601" is the container ID

Install

@gogson
gogson / packer-esxi-static-network.json
Last active December 7, 2020 22:02
Packer ESXi remote build with static network configuration
{
"vm_name": "my-vm",
"remote_type": "esx5",
"remote_host": "exsi.myhost.com",
"remote_password": "myEsxiRootPassword",
"remote_datastore": "datastore1",
"type": "vmware-iso",
"output_directory": "output-vm",
"floppy_files": [
"preseed.cfg",
@ebenolson
ebenolson / preseed.cfg
Created October 14, 2015 18:00
packer ubuntu 14.04 esxi
choose-mirror-bin mirror/http/proxy string
d-i base-installer/kernel/override-image string linux-server
d-i clock-setup/utc boolean true
d-i clock-setup/utc-auto boolean true
d-i finish-install/reboot_in_progress note
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string lvm
@mnot
mnot / snowden-ietf93.md
Last active March 9, 2026 19:22
Transcript of Edward Snowden's comments at IETF93.
@gane5h
gane5h / datadog-nginx
Created October 22, 2014 04:06
Nginx log parsing with datadog
"""
Custom parser for nginx log suitable for use by Datadog 'dogstreams'.
To use, add to datadog.conf as follows:
dogstreams: [path to ngnix log (e.g: "/var/log/nginx/access.log"]:[path to this python script (e.g "/usr/share/datadog/agent/dogstream/nginx.py")]:[name of parsing method of this file ("parse")]
so, an example line would be:
dogstreams: /var/log/nginx/access.log:/usr/share/datadog/agent/dogstream/nginx.py:parse
Log of nginx should be defined like that:
log_format time_log '$time_local "$request" S=$status $bytes_sent T=$request_time R=$http_x_forwarded_for';
when starting dd-agent, you can find the collector.log and check if the dogstream initialized successfully
"""
@DTFagus
DTFagus / analyse_watchers.js
Created August 12, 2014 14:22
Bookmarklet to analyse angular watchers
javascript: (function() {
var root = $(document.getElementsByTagName('html'));
var watchers = [];
var attributes = [];
var attributes_with_values = [];
var elements = [];
var elements_per_attr = [];
var scopes = [];
var debugWatchers = function(selector, showExp) {
var target, i, checkInsideFn, jq, items,
nb_watchers = 0,
nb_scopes = 0,
scopes_id = {};
if(typeof jQuery == 'undefined') {
jq = document.createElement('script');
jq.type = 'text/javascript';
jq.src = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js';
@joewagner
joewagner / Sharded mongodb environment on localhost
Last active May 7, 2024 13:33
Bash shell script that sets up a sharded mongodb cluster on a single machine. Handy for testing or development when a sharded deployment is required. Notice that this will remove everything in the data/config and data/shard directories. If you are using those for something else, you may want to edit this...
# clean everything up
echo "killing mongod and mongos"
killall mongod
killall mongos
echo "removing data files"
rm -rf data/config
rm -rf data/shard*
# For mac make sure rlimits are high enough to open all necessary connections
ulimit -n 2048