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 'digest' | |
def get_hash(string=nil, file=nil, method='md5') | |
raise RuntimeError if string.nil? && file.nil? | |
method = method.upcase | |
method = Digest.class_eval(method) | |
if string | |
hash = method.hexdigest(string) |
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
module Functional | |
def apply(enum) | |
enum.map &self | |
end | |
alias | apply | |
def reduce(enume) | |
enum.inject &self | |
end | |
alias <= reduce |
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 'optparse' | |
options = {} | |
optparse = OptionParser.new do |opts| | |
options[:verbose] = false | |
opts.banner = "Usage: #{$0} --option=value" | |
opts.on('-v', '--verbose') {options[:verbose] = true} | |
opts.on('-h', '--help') do | |
puts "Help message" |
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/sh | |
### BEGIN INIT INFO | |
# Provides: btsync | |
# Required-Start: $local_fs $remote_fs | |
# Required-Stop: $local_fs $remote_fs | |
# Should-Start: $network | |
# Should-Stop: $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Multi-user daemonized version of btsync. |
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
rsync -av -e ssh pi@192.168.0.1:~/logs/* ./logs/ # копирование с помощью rsync |
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
# Gemfile | |
gem 'rails_admin' | |
gem 'paperclip' |
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
package main | |
import "fmt" | |
func main(){ | |
a := 3 | |
if a == 3 { | |
fmt.Println("1. if-else, a == 3") | |
} else { | |
fmt.Println("1. if-else, a != 3") |
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
import timeit | |
time_python = timeit.timeit(""" | |
from itertools import groupby | |
from random import randint | |
import pandas as pd | |
accruals = [ | |
{'account': i, 'value': i * randint(0, 20), 'foo': randint(0, 10)} | |
for i in range(5000) |
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
package main | |
import "log" | |
func groupBy(vars []int) map[int][]int { | |
result := make(map[int][]int) | |
for _, value := range vars { | |
result[value] = append(result[value], value) | |
} |
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
var numCPUs = require('os').cpus().length; | |
var cluster = require('cluster'); | |
var count=0; | |
if (cluster.isMaster) { | |
for (var i = 0; i < numCPUs; i++) { | |
cluster.fork(); | |
} | |
cluster.on('exit', function(worker, code, signal) { |
OlderNewer