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 / php.xml
Created October 5, 2017 03:57
PHP coding style in phpstorm
<code_scheme name="PHP">
<MarkdownNavigatorCodeStyleSettings>
<option name="RIGHT_MARGIN" value="72" />
</MarkdownNavigatorCodeStyleSettings>
<PHPCodeStyleSettings>
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
<option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
<option name="ALIGN_PHPDOC_COMMENTS" value="true" />
<option name="COMMA_AFTER_LAST_ARRAY_ELEMENT" value="true" />
<option name="PHPDOC_BLANK_LINE_BEFORE_TAGS" value="true" />
@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) {
0x76a2dc055c39f0bd7c9cb450ba317c25e4f540ef
@mrsinguyen
mrsinguyen / usb.md
Last active July 20, 2017 02:59
Creating A Bootable USB

Creating A Bootable USB from ISO on OSX

  1. Download the ISO you want to use
  2. Open Terminal (in /Applications/Utilities)
  • Navigate to the path where the .iso file is located
  • Use ls to list all the folders
  • cd /path/to/iso to dive in to folder or cd .. to go back the path
  1. Convert .iso to .img using hdiutil: hdiutil convert -format UDRW -o /path/to/target.img /path/to/source.iso
  2. Rename if OS X gave it a .dmg ending: mv /path/to/target.img.dmg path/to/target.img
@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 / unpack-create.sh
Created July 5, 2017 00:44
Unpack & create a Java .war file on Mac OX
# Extract
jar -xvf sample.war
# Create
jar -cvf sample.war *
@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 / 0.md
Last active May 16, 2017 01:43
St.

Hải Phòng ngày 4 tháng 10 năm 2035

Tuyền thân mến,

Khang đây, vậy là đã hơn 20 năm rồi kể từ lần cuối chúng mình gặp nhau nhỉ? Sao hôm trước lớp mình họp lớp cậu lại không đi, các bạn đến đông đủ lắm, thiếu mỗi cậu thôi. Bây giờ trông ai cũng xinh và sự nghiệp thành đạt lắm, gặp ngoài đường mà không nhận ra luôn. Trường mình cũng khác xưa nhiều rồi. Mình viết thư này để kể cho cậu nghe về sự thay đổi của trường trung học cơ sở 20 năm qua nhé.

20 năm trôi qua, đủ để cho mỗi người gây dựng cho mình một cơ ngơi vững trãi. Mình cũng vậy, ước mơ nhỏ bé thống trị thế giới của mình đang trở thành hiện thực cậu ạ, hiện tại tớ đang giữ cương vị làm Bộ trưởng Bộ Quốc phòng kiêm Bộ trưởng Bộ giáo dục.

Nếu cậu đang thắc mắc sao tớ vừa đẹp trai, thông minh và đa tài như vậy thì đây chính là bí mật mà tớ không thể bật mí. À mà cậu đã lấy chồng chưa? hình như là chưa hả. Tớ thì chủ nhật tuần này lấy vợ thứ 20 rồi, cô ấy 18 tuổi, là người mẫu ảnh, xinh lắm.

@mrsinguyen
mrsinguyen / docker-mysql56.sh
Last active June 15, 2017 03:24
Run mysql as docker
docker run --name mysql-56 -p 3307:3306 -v /Users/mrsinguyen/Workspaces/GO1/DB/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Password -e MYSQL_ROOT_HOST=172.17.0.1 -d mysql:5.6