Skip to content

Instantly share code, notes, and snippets.

View mrsinguyen's full-sized avatar
🎯
Focusing

Si Nguyen mrsinguyen

🎯
Focusing
View GitHub Profile
@mrsinguyen
mrsinguyen / git-dmz-flow.md
Created October 6, 2017 02:45 — 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
@mrsinguyen
mrsinguyen / index.php
Created August 30, 2017 00:45 — forked from micronax/index.php
Render XML-Data using Twig-Template within the SILEX-Microframework
<?php
// Add to use-statements
use Symfony\Component\HttpFoundation\Response;
// [...] Your application code
// Action to return XML from Twig-Template
$app->get(
'/sitemap.xml',
function () use ($app) {
@mrsinguyen
mrsinguyen / forwarder.sol
Created July 17, 2017 06:52 — forked from izqui/forwarder.sol
Very cheap to deploy (66k gas) forwarder contracts that can clone any contract and still have their own storage
// Bytecode origin https://www.reddit.com/r/ethereum/comments/6ic49q/any_assembly_programmers_willing_to_write_a/dj5ceuw/
// Modified version of Vitalik's https://www.reddit.com/r/ethereum/comments/6c1jui/delegatecall_forwarders_how_to_save_5098_on/
// Credits to Jordi Baylina for this way of deploying contracts https://gist.github.com/jbaylina/e8ac19b8e7478fd10cf0363ad1a5a4b3
// Forwarder is slightly modified to only return 256 bytes (8 normal returns)
// Deployed Factory in Kovan: https://kovan.etherscan.io/address/0xaebc118657099e2110c90494f48b3d21329b23eb
// Example of a Forwarder deploy using the Factory: https://kovan.etherscan.io/tx/0xe995dd023c8336685cb819313d933ae8938009f9c8c0e1af6c57b8be06986957
// Just 66349 gas per contract
@mrsinguyen
mrsinguyen / icos.md
Created June 5, 2017 06:01
ICOs & Custom Cryptocurrencies On Ethereum Classic

fund raising

Many initiatives are raising capital via initial coin offerings (ICOs). The Ethereum (ETH) project raised 18 million dollars and the DAO project raised 150 million of dollars! Furthermore, the entire blockchain space is worth over 90 billion dollars! I will describe ICOs and their custom cryptocurrencies on Ethereum Classic (ETC).

ICO Basics

ICO

An ICO is a method of raising funds via the sale of a new cryptocurrency. These cryptocurrencies are often required to purchase goods and services from the issuing organizations. For example, the ETH cryptocurrency (ether) is used to rent ETH system resources. Typically ICOs are announced on Bitcointalk.org forums and heavily marketed beforehand. Buyers often purchase new cryptocurrencies by sending bitcoins or ether to an escrow account. Organizations set the initial prices then supply and demand determines the

@mrsinguyen
mrsinguyen / localstorage_safari_private_shim.js
Created May 16, 2017 10:00 — forked from philfreo/localstorage_safari_private_shim.js
Don't let localStorage/sessionStorage setItem throw errors in Safari Private Browsing Mode
// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem
// throw QuotaExceededError. We're going to detect this and just silently drop any calls to setItem
// to avoid the entire page breaking, without having to do a check at each usage of Storage.
if (typeof localStorage === 'object') {
try {
localStorage.setItem('localStorage', 1);
localStorage.removeItem('localStorage');
} catch (e) {
Storage.prototype._setItem = Storage.prototype.setItem;
Storage.prototype.setItem = function() {};
@mrsinguyen
mrsinguyen / local-storage-size.js
Created March 24, 2017 07:08 — forked from cdmckay/local-storage-size.js
Detects the size of the browser's localStorage
if (localStorage && !localStorage.getItem('size')) {
var i = 0;
try {
// Test up to 10 MB
for (i = 250; i <= 10000; i += 250) {
localStorage.setItem('test', new Array((i * 1024) + 1).join('a'));
}
} catch (e) {
localStorage.removeItem('test');
localStorage.setItem('size', i - 250);
@mrsinguyen
mrsinguyen / Web Components Resources.md
Created March 21, 2017 12:47 — forked from ebidel/Web Components Resources.md
List of resources related to Web Components
@mrsinguyen
mrsinguyen / recover_source_code.md
Created March 12, 2017 09:51 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@mrsinguyen
mrsinguyen / root.sh
Created October 27, 2016 04:53 — forked from Arinerron/root.sh
"Root" via dirtyc0w privilege escalation exploit (automation script) / Android (32 bit)
#!/bin/bash
# Give the usual warning.
clear;
echo "[INFO] Automated Android root script started.\n\n[WARN] Exploit requires sdk module \"NDK\".\nFor more information, visit the installation guide @ https://goo.gl/E2nmLF\n[INFO] Press Ctrl+C to stop the script if you need to install the NDK module. Waiting 10 seconds...";
sleep 10;
clear;
# Download and extract exploit files.
echo "[INFO] Downloading exploit files from GitHub...";
@mrsinguyen
mrsinguyen / README.txt
Created September 28, 2016 08:40 — forked from cruppstahl/README.txt
upscaledb-mysql 0.0.1: initial benchmarks
These files were used to create the benchmarks for the release of upscaledb-mysql 0.0.1.
=== sysbench
Use sysbench 1.0. The shell script loads and runs the tests.
I ran various tests - with and without transactions, with LOCK TABLE etc. Results are in sysbench-results.txt.
=== uqi1
This script performs a `SELECT COUNT(*) FROM table`. The table was from TPC-C order_line with 6 million rows.