Skip to content

Instantly share code, notes, and snippets.

View codenoid's full-sized avatar

codenoid

  • Wonogiri, Jawa Tengah
  • 07:09 (UTC +07:00)
View GitHub Profile
require "kemal"
require "jwt"
require "json"
require "yaml"
require "arangocr"
require "redis"
# Load .env file
env_data = YAML.parse File.read(".env.yml") rescue Hash(String, String).new
env_data.each { |k, v| ENV[k.to_s] = v.to_s }
# Check your passwords against https://haveibeenpwned.com/Passwords
# Usage:
# crystal run --release check_passwords.cr -- pwned-passwords*.txt
# Enter your passwords one per line, then press Return twice
require "digest/sha1"
my_passwords = Hash(String, String).new
until (line = gets || "").empty?
my_passwords[Digest::SHA1.hexdigest(line).upcase] = line
@codenoid
codenoid / nyemod.md
Last active September 11, 2017 07:53
Penggunaan Nyemod di blogger / wordpress
  1. buat widget baru, text/html | text/script
  2. masukkan kode dibawah ini
<script src="https://cdn.rawgit.com/codenoid/Nyemod/master/lib/nyemod.min.js"></script>
<script>
	Nyemod.init({
		click: 3, // total klik maksimal, dan akan di reset jika sudah melewati waktu
		interval: 23000 // reload time in ms
	});
@codenoid
codenoid / puppeteer.run
Created September 6, 2017 10:24
Run Puppeteer
Works perfectly on ubuntu xenial - no gtk - remote - ssh - non root
Linux ip---- 4.4.0-1022-aws #31-Ubuntu SMP Tue Jun 27 11:27:55 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu Xenial
update
sudp apt-get update
node v8.4.0
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs
Install npm
@codenoid
codenoid / needed.sh
Created September 6, 2017 13:45
Crystal needed Library
sudo apt-get install \
libbsd-dev \
libedit-dev \
libevent-core-2.0-5 \
libevent-dev \
libevent-extra-2.0-5 \
libevent-openssl-2.0-5 \
libevent-pthreads-2.0-5 \
libgmp-dev \
libgmpxx4ldbl \
@codenoid
codenoid / matchmacro.nim
Created September 11, 2017 07:18 — forked from mashingan/matchmacro.nim
defining match syntax using Nim macro
import macros
macro match(head, body: untyped): untyped =
result = newNimNode nnkStmtList
var casenode = newNimNode nnkCaseStmt
casenode.add head
for node in body:
node.expectKind nnkInfix
<?php
# "pilih device|freq => port"
$args = array("0|1800" => "5000", "1|1820" => "4000", "2|1730" => "3000");
foreach($args as $key => $port) {
$parse = explode("|", $key);
$d = $parse[0]; # device number
$f = $parse[1]; # frequent
shell_exec("grgsm_livemon_headless args=rtl=$d --serverport=$port -f $f > /dev/null 2>/dev/null &");
}
vim /etc/rc.local
module Indexable(T)
def threadpool_map(workers : Int = 8, chunk_size : Int? = nil, &func : T -> R) forall T, R
mutex = Thread::Mutex.new
cs = chunk_size || (self.size**0.5).ceil.to_i
Array(R).build(self.size) do |result|
index = 0
threads = Array.new(workers) {
Thread.new do
a = b = 0
loop do