Skip to content

Instantly share code, notes, and snippets.

@amalrik
amalrik / move_sqlserver.sh
Created July 30, 2017 14:58
move sqlserver backup file
$ sudo mkdir -p /var/opt/mssql/backup
$ sudo mv /home/user/usersdb_erp_bc.bak /var/opt/mssql/backup/
@amalrik
amalrik / restore_filelistonly.sql
Created July 30, 2017 14:42
list files on sqlserver backup
1> RESTORE FILELISTONLY from DISK = '/var/opt/mssql/backup/usersdb_erp_bc.bak'
2> GO
LogicalName PhysicalName Type FileGroupName Size MaxSize FileId CreateLSN DropLSN UniqueId ReadOnlyLSN ReadWriteLSN BackupSizeInBytes SourceBlockSize FileGroupId LogGroupGUID DifferentialBaseLSN DifferentialBaseGUID IsReadOnly IsPresent TDEThumbprint
@amalrik
amalrik / bundle_output
Created July 1, 2016 21:44
trix bundle install output
$ bundle
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Using rake 10.0.4
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.9.0
Using thread_safe 0.3.5
Using addressable 2.4.0
@amalrik
amalrik / setup_output
Created July 1, 2016 21:42
trix bin/setup output
$ bundle exec bin/setup -v
--- Installing Ruby gems
Illegal option -s
Usage: /usr/bin/which [-a] args
Illegal option -s
Usage: /usr/bin/which [-a] args
Illegal option -s
Usage: /usr/bin/which [-a] args
Can't find or install Ruby. Install it from https://www.ruby-lang.org or with https://github.com/rbenv/rbenv
@amalrik
amalrik / example.coffee
Created May 4, 2016 20:34
Example configuration for karma-coffee preprocessor.
// This file locate in directory 'test'
describe 'test suite', ->
it 'should pass', ->
expect(true).toEqual(true)
it 'should fail', ->
expect(true).toEqual(false)
@amalrik
amalrik / fallout.rb
Created December 3, 2015 16:49 — forked from tenderlove/fallout.rb
hack fallout terminals
##
# Program to help you hack terminals in Fallout
#
# Usage:
#
# Run the program once with a list of words in the terminal. The program will
# output a list, and the first word in the list is the word you should pick
# because it will eliminate the most possibilities.
#
# If that word is incorrect, then re-run the program with two lists, first the
# inspired by https://mriet.wordpress.com/2012/07/01/merge-bubbles-are-bad/
# and http://snipplr.com/view/26715/
# 1. first rebase all your local commits into one commit, e.g. for the last 3 commits into one you can use
git rebase -i HEAD~3
# and 'pick' the first, 'squash' the other commits
# 2. check the commit's sha id and save it somewhere

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

def generate_authentication_token
loop do
token = Devise.friendly_token
hashed_token = BCrypt::Password.create(token)
update_attribute(:token_id, Devise.friendly_token)
final_token = "#{token_id}-#{token}"
break { token: final_token, hashed_token: hashed_token } unless User.where(authentication_token: hashed_token).first
end
@amalrik
amalrik / gist:9765773
Last active August 29, 2015 13:57 — forked from RiANOl/gist:1077760
aes128/256
require "openssl"
require "digest"
def aes128_encrypt(key, data)
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize)
aes = OpenSSL::Cipher.new('AES-128-CBC')
aes.encrypt
aes.key = key
aes.update(data) + aes.final
end