Skip to content

Instantly share code, notes, and snippets.

View widnyana's full-sized avatar
🤘
available for hire

wid widnyana

🤘
available for hire
View GitHub Profile
@widnyana
widnyana / Documentation.md
Created March 17, 2017 13:51 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@widnyana
widnyana / gist:fda560fe943f187b7d2dee30473bb5d6
Created January 30, 2017 15:56 — forked from zxvdr/gist:5624054
RPC tracing for Golang (ala Dapper)
diff --git a/client.go b/client.go
index 4b0c9c3..8ac98e4 100644
--- a/client.go
+++ b/client.go
@@ -32,6 +32,7 @@ type Call struct {
Reply interface{} // The reply from the function (*struct).
Error error // After completion, the error status.
Done chan *Call // Strobes when call is complete.
+ Trace uint32 // unique id used for tracing
}
@widnyana
widnyana / .golang-example-gitlab-ci.yml
Created October 10, 2016 09:48 — forked from mikeatlas/.golang-example-gitlab-ci.yml
Example Go GitLab CI setup (no root/sudo required)
# See docs/examples
# http://doc.gitlab.com/ce/ci/quick_start/README.html
# http://doc.gitlab.com/ce/ci/yaml/README.html
# GitLab CI template for Go tests. Note this installs
# a new working copy of Go in a non-standard path such
# that sudo/root is not needed for the install stage.
# note that this particular install-environment stage
# is overly verbose in order to debug anything tricky
@widnyana
widnyana / dump.sh
Created June 24, 2016 06:01
Dump Current Nginx Config
# Set pid of nginx master process here
pid=8192
# generate gdb commands from the process's memory mappings using awk
cat /proc/$pid/maps | awk '$6 !~ "^/" {split ($1,addrs,"-"); print "dump memory mem_" addrs[1] " 0x" addrs[1] " 0x" addrs[2] ;}END{print "quit"}' > gdb-commands
# use gdb with the -x option to dump these memory regions to mem_* files
gdb -p $pid -x gdb-commands
# look for some (any) nginx.conf text
@widnyana
widnyana / VarDumperServiceProvider.php
Created June 21, 2016 10:23
Silex 1.3 VarDumperServiceProvider
<?php
namespace App\Providers;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\VarDumper;
@widnyana
widnyana / playbook.yml
Created February 16, 2016 10:43
ansible virtualenv trick
- template: src=templates/venv_exec.j2 dest={{ om_venv_path }}/exec mode=755
- command: "{{ om_venv_path }}/exec pip install -U pip"
- command: "{{ om_venv_path }}/exec which pip"
@widnyana
widnyana / merge.py
Created January 8, 2016 11:44
merge multi image into one using pillow
# -*- coding: utf-8 -*-
from PIL import Image
source = [
'picture_to_merge.page_0.jpg',
'picture_to_merge.page_1.jpg',
'picture_to_merge.page_2.jpg',
'picture_to_merge.page_3.jpg',
'picture_to_merge.page_4.jpg',
]
@widnyana
widnyana / imdb_next_page_spider.py
Created January 6, 2016 07:23 — forked from premit/imdb_next_page_spider.py
Scrapy reference: Crawling next pagination
'''
Spider for IMDb
- Retrieve most popular movies & TV series with rating of 8.0 and above
- Crawl next pages recursively
'''
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import Selector
@widnyana
widnyana / XController.php
Created November 30, 2015 09:37
Lumen Framework - Send Image via ResponseStream
<?php
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
class XController
{
public function getView(Request $r, $loc='')
{
@widnyana
widnyana / python.py
Created November 24, 2015 10:09
sering lupa
script_current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))