Skip to content

Instantly share code, notes, and snippets.

Ta Dat suplo

Block or report user

Report or block suplo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@suplo
suplo / elb.py
Created Jul 19, 2018 — forked from philfreo/elb.py
Python script to remove/add an EC2 instance into an AWS ELB. Helpful during deployments. (Using Flask / Flask-Script but easily modifiable)
View elb.py
#!/usr/bin/env python
import time
import boto
import boto.ec2.elb
import boto.utils
from flask.ext.script import Manager
from closeio.main import setup_app
View gist:1c3656649acc9232d94c99714f38ac62
$: (Dollar Colon) is basically a shorthand version of $LOAD_PATH. $: contains an array of paths that your script will search through when using require.
$0 (Dollar Zero) contains the name of the ruby program being run. This is typically the script name.
$* (Dollar Splat) is basically shorthand for ARGV. $* contains the command line arguments that were passed to the script.
$? (Dollar Question Mark) returns the exit status of the last child process to finish.
$$ (Dollar Dollar) returns the process number of the program currently being ran.
$~ (Dollar Tilde) contains the MatchData from the previous successful pattern match.
$1, $2, $3, $4 etc represent the content of the previous successful pattern match.
$& (Dollar Ampersand) contains the matched string from the previous successful pattern match.
$+ (Dollar Plus) contains the last match from the previous successful pattern match.
$` (Dollar Backtick) contains the string before the actual matched string of the previous successful pattern match.
@suplo
suplo / what-forces-layout.md
Created Jul 9, 2018 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@suplo
suplo / htmlentity.js
Created Apr 11, 2018 — forked from CatTail/htmlentity.js
Javascript: encode(decode) html text into html entity
View htmlentity.js
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
@suplo
suplo / performance.txt
Created Dec 28, 2017 — forked from dstroot/performance.txt
Performance Tuning your TCP Stack
View performance.txt
#!/bin/bash
echo "*****************************************"
echo " Based on information from Google"
echo " http://dev.chromium.org/spdy/spdy-best-practices"
echo "*****************************************"
sudo su
yum –y update
echo "*****************************************"
echo " Changing initcwnd and initrwnd"
echo " Step 1: check route settings."
@suplo
suplo / gist:850e658be1badd735685fb1e1163aa13
Created Dec 25, 2017 — forked from solenoid/gist:1372386
javascript ObjectId generator
View gist:850e658be1badd735685fb1e1163aa13
var mongoObjectId = function () {
var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
return (Math.random() * 16 | 0).toString(16);
}).toLowerCase();
};
@suplo
suplo / awk-example.sh
Created Dec 6, 2017 — forked from raecoo/awk-example.sh
awk/grep commands for Rails log analysis
View awk-example.sh
# Access number
cat production.log | grep "^Processing" | wc | awk '{print $1}'
# Each IP access number
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq -c
# Independent IP number
cat production.log | grep "^Processing" | awk '{print $4}' | uniq | wc | awk '{print $1}'
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq | wc -l
View snarktest.solidity
pragma solidity ^0.4.14;
library Pairing {
struct G1Point {
uint X;
uint Y;
}
// Encoding of field elements is: X[0] * z + X[1]
struct G2Point {
uint[2] X;
@suplo
suplo / gist:c3eff82edab317f6e4a50cc943f7fcae
Created Jul 14, 2017
Split a file into multiple chunk by lines count
View gist:c3eff82edab317f6e4a50cc943f7fcae
https://stackoverflow.com/questions/40509083/vim-split-one-file-into-multiple-files-based-on-row-count
up vote
8
down vote
accepted
First, you define a control variable:
:let i = 1
Then, you write lines 1 to 99 (inclusive) to a file named after the current value of the control variable, cut those line, and increment the control variable;
@suplo
suplo / MySQL_macOS_Sierra.md
Created Jul 5, 2017 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew
View MySQL_macOS_Sierra.md

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

You can’t perform that action at this time.