Skip to content

Instantly share code, notes, and snippets.

@Zai
Zai / Ethereum_private_network.md
Created March 14, 2018 09:07 — forked from 0mkara/Ethereum_private_network.md
Ethereum private network configuration guide.

Create your own Ethereum private network

Introduction

Used nodes:

Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux
Linux localhost.localdomain 4.14.5-200.fc26.x86_64 #1 SMP Mon Dec 11 16:29:08 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
@Zai
Zai / encrypt_decrypt.rb
Created February 8, 2018 19:12 — forked from wteuber/encrypt_decrypt.rb
Simply encrypt and decrypt Strings in ruby.
require 'openssl'
class String
def encrypt(key)
cipher = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC').encrypt
cipher.key = Digest::SHA1.hexdigest key
s = cipher.update(self) + cipher.final
s.unpack('H*')[0].upcase
end
@Zai
Zai / meta-tags.md
Last active August 29, 2015 14:11 — forked from kevinSuttle/meta-tags.md

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
# Sum feature's price and convert to cents
amount = self.features.inject(0) { |sum, feature| sum + feature.price}
amount_in_cents = (amount * 100).to_i
# Create needed Paymill object (client / payment / offer / subscription)
client = Paymill::Client.create email: email, description: name
payment = Paymill::Payment.create token: paymill_card_token, client: client.id
offer = Paymill::Offer.create amount: amount_in_cents, currency: "EUR", interval: "1 MONTH", name: "Subscription for #{name}"
subscription = Paymill::Subscription.create offer: offer.id, client: client.id, payment: payment.id
@Zai
Zai / unicorn.rb
Last active December 19, 2015 09:39
# config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 30
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
@Zai
Zai / recalc.rb
Last active December 19, 2015 04:59
def recalc
['right', 'left'].each do |side|
if send("#{side}_eye_cylinder").to_f < 0
send("#{side}_eye_sphere=", send("#{side}_eye_sphere").to_f + send("#{side}_eye_cylinder").to_f )
send("#{side}_eye_cylinder=", send("#{side}_eye_cylinder").to_f.abs )
if send("#{side}_eye_axe").to_i < 90
send("#{side}_eye_axe=", send("#{side}_eye_axe").to_i + 90)
else
send("#{side}_eye_axe=", send("#{side}_eye_axe").to_i - 90)
end
@Zai
Zai / gist:3930588
Created October 22, 2012 09:24
.tm_properties for rails apps
# ---------------------------------------------------------
# Display the name of the home directory
# ---------------------------------------------------------
windowTitle = "$TM_DISPLAYNAME - ${CWD/^.*\///}"
# ---------------------------------------------------------
# Configure Git
# ---------------------------------------------------------
TM_GIT = "/usr/local/git/bin/git"