Skip to content

Instantly share code, notes, and snippets.

View andreiashu's full-sized avatar

Andrei Simion andreiashu

View GitHub Profile
@andreiashu
andreiashu / Vagrantfile
Last active December 26, 2015 08:29
Centos 6.4 and Docker as a Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
BOX_NAME = ENV['BOX_NAME'] || "Centos6.4"
BOX_URI = ENV['BOX_URI'] || "http://shonky.info/centos64.box"
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@andreiashu
andreiashu / jenkins-self-backup.sh
Created August 19, 2014 15:09
Jenkins self-backup to S3 job
cd /var/lib
tar czf ${WORKSPACE}/ecm_jenkins.tar.gz --exclude='*.log' --exclude='jenkins/jobs/*/builds/*' --exclude='jenkins/jobs/*/workspace/*' jenkins
s3cmd put ${WORKSPACE}/ecm_jenkins.tar.gz s3://[bucket-name]/ecm_jenkins.tar.gz
@andreiashu
andreiashu / git-dmz-flow.md
Created June 30, 2016 14:08 — forked from djspiewak/git-dmz-flow.md
Git DMZ Flow

Git DMZ Flow

I've been asked a few times over the last few months to put together a full write-up of the Git workflow we use at RichRelevance (and at Precog before), since I have referenced it in passing quite a few times in tweets and in person. The workflow is appreciably different from GitFlow and its derivatives, and thus it brings with it a different set of tradeoffs and optimizations. To that end, it would probably be helpful to go over exactly what workflow benefits I find to be beneficial or even necessary.

  • Two developers working on independent features must never be blocked by each other
    • No code freeze! Ever! For any reason!
  • A developer must be able to base derivative work on another developer's work, without waiting for any third party
  • Two developers working on inter-dependent features (or even the same feature) must be able to do so without interference from (or interfering with) any other parties
  • Developers must be able to work on multiple features simultaneously, or at lea
@andreiashu
andreiashu / index.js
Created May 24, 2017 22:23
bluebird handling unhandled rejections
const Promise = require('bluebird');
// bluebird unhandledRejection event
process.on('unhandledRejection', function (reason, promise) {
console.log(`unhandledRejection, reason ${reason}`, promise);
// don't continue in this state you plonker!
process.exit(1);
});
@andreiashu
andreiashu / gdn_datapoint_schema.sql
Last active September 9, 2017 09:53
GDN DATA SQL TABLE SCHEMA
CREATE TABLE `datapoints` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`lineid` varchar(255) DEFAULT NULL,
`geolocation` point DEFAULT NULL,
`price` float NOT NULL,
`currency` varchar(20) NOT NULL DEFAULT '',
`locname` text DEFAULT NULL,
`time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
@andreiashu
andreiashu / bash_obliterate.sh
Created October 1, 2017 01:46
WARNING! this will obliterate absolutely all your Docker containers and images. I'm using it on an OSX installation to get rid of the pesky "No space left on device" error (with plenty of free space on my disk). Put it in your ~/.bashrc or ~/.zshrc and run it with `pwndocker`
# PWN that sucker!
# Warning: completely obliterates Docker: removes all containers, images and volumes
# add this function to your ~/.bash_profile or ~/.zshrc (or equivalent)
pwndocker() {
echo -n "You sure you want to pwn Docker (y/n)? "
read answer
if echo "$answer" | grep -iq "^y$" ;then
[[ -n $(docker ps -qa) ]] && docker kill $(docker ps -qa)
[[ -n $(docker ps -qa) ]] && docker rm -v $(docker ps -qa)
[[ -n $(docker images -q) ]] && docker rmi -f $(docker images -q)
@andreiashu
andreiashu / rinkeby.wallet
Created November 9, 2017 14:38
0x518d4640876362611fd93a177bf5f2a7b01f873c
0x518d4640876362611fd93a177bf5f2a7b01f873c
@andreiashu
andreiashu / jest.test.ts
Created July 31, 2018 06:01
Jest tests that helped me understand how different Jest settings behave
describe("Understand Jest framework", () => {
test("async works with Promise.resolve", async () => Promise.resolve(true))
test("async works with return", async () => true)
test("async works with expect met", async () => expect(true).toBe(true))
test("expect throws", async () => {
try {
expect(true).toBe(false)
console.log('This should not be printed')
} catch (err) {
// silence the error
@andreiashu
andreiashu / load-web3.js
Created October 20, 2021 03:45
Load Web3 within browser console
// paste this in your browser's console
(function() {
_loadScript = function(path){ var script= document.createElement('script'); script.type= 'text/javascript'; script.src= path; document.head.appendChild(script); }
_loadScript('https://cdnjs.cloudflare.com/ajax/libs/web3/1.6.1-rc.0/web3.min.js');
// @TODO: this can fail on slow connections; should have a retry mechanism
setTimeout(() => {
console.log(`Loaded Web3 version: ${Web3.version}`);
}, 1500);
@andreiashu
andreiashu / load-ethersjs.js
Created October 20, 2021 04:03
Load ethers in browser console
// paste this in your browser's console
(function() {
_loadScript = function(path){ var script= document.createElement('script'); script.type= 'text/javascript'; script.src= path; document.head.appendChild(script); }
_loadScript('https://cdn.jsdelivr.net/npm/ethers@5.5.0/dist/ethers.umd.js');
// @TODO: this can fail on slow connections; should have a retry mechanism
setTimeout(() => {
console.log(`Loaded ethersjs version: ${ethers.version}`);
}, 1500);