Skip to content

Instantly share code, notes, and snippets.

@suplo
suplo / gist:850e658be1badd735685fb1e1163aa13
Created December 25, 2017 02:29 — forked from solenoid/gist:1372386
javascript ObjectId generator
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 December 6, 2017 03:45 — forked from raecoo/awk-example.sh
awk/grep commands for Rails log analysis
# 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
@suplo
suplo / snarktest.solidity
Created September 19, 2017 16:26 — forked from chriseth/snarktest.solidity
zkSNARKs test code
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 July 14, 2017 01:38
Split a file into multiple chunk by lines count
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 July 5, 2017 15:13 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew

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 :

@suplo
suplo / redis_cheatsheet.bash
Created June 25, 2017 08:53 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@suplo
suplo / simple.html
Created June 18, 2017 08:42
Simple html file
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p>first sentence</p>
<p>second sentence</p>
<div><span>another sentence</span></div>
</body>
</html>
@suplo
suplo / exec.sh
Created June 14, 2017 02:42
exec code
#!/usr/bin/env bash
# execute command
$@
# check status
STATUS=$?
if [ $STATUS == 0 ]; then
echo "Command '$@' completed successfully"
else
@suplo
suplo / README.md
Created June 13, 2017 01:30 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
@suplo
suplo / regex.md
Created June 7, 2017 10:43
Url regex