This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def map | |
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" | |
end | |
def encode64 | |
self.bytes.to_a.map {|a|a.ord.to_s(2).rjust(8, '0')}.join.scan(/.{6}/).map {|a|map[a.to_i(2)]}.join | |
end | |
def decode64 | |
self.split('').map {|a|map.index(a)}.map {|a|a.to_s(2).rjust(6,'0')}.join.scan(/.{8}/).map{|a|a.to_i(2).chr}.join | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
N = 10_000 | |
LENGTH = 100 | |
STR1, STR2, STR3 = "a", "b" * LENGTH, "c" | |
puts "LENGTH: " << (STR1.size + STR2.size + STR3.size).to_s | |
Benchmark.bm(10) do |x| | |
x.report('"" < STR1 << STR2 << STR3') do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on_worker_boot do | |
request_thread_count = Puma.cli_config.options[:max_threads] | |
Sidekiq.configure_client do |cfg| | |
cfg.redis = ConnectionPool.new(:size => 10, :timeout => 3) { Redis.connect } | |
end | |
cmdline = `cat /proc/#{$$}/cmdline` | |
# compress assets | |
# reference: app.rb - L:97 | |
if Puma.cli_config.options[:environment] == 'production' and cmdline.include? 'worker 0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding: utf-8 -*- | |
import contextlib | |
import re | |
import urllib | |
from bs4 import BeautifulSoup | |
from datetime import datetime | |
from textwrap import dedent as trim | |
now = lambda: datetime.now().strftime("%Y%m%d%H") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import pep8 | |
class Writer: | |
def __init__(self, exclude=[], stdout=None): | |
self.content = [] | |
self.exclude = exclude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from sys import argv, exit | |
cac = [] | |
res = [] | |
words = [] | |
M = 0 | |
for x in range(1000): | |
cac.append([-1 for j in range(1000)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDate(decrease) { | |
var date = new Date(); | |
if(decrease && decrease > 0) { | |
date = new Date(date); | |
date.setDate(date.getDate() - decrease); | |
} | |
var yyyy = date.getFullYear().toString(), | |
dd = date.getDate().toString(), | |
mm = (date.getMonth() + 1).toString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
NAME=$1 | |
FROM=$2 | |
PIDFILE=".$1.pid" | |
DIR=$(pwd) | |
PERIOD=${3:-7} | |
PRIORITY=${4:-10} | |
FILENAME="$(date +%Y-%m-%d_%H%M).tar.gz" | |
BACKUPDIR="$DIR/backups/$NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('display_error', 1); | |
error_reporting(E_ALL & ~E_NOTICE); | |
class skyDriveDL { | |
// Location | |
private $loc; | |
// File | |
private $file; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* layout | |
-------------------------------------*/ | |
body { | |
margin: 0 3.5%; | |
padding: 0; | |
font-family: 'NanumGothic'; | |
} | |
p, h2, tr, td, td a, select { | |
font-family: 'NanumGothic'!important; |
OlderNewer