Skip to content

Instantly share code, notes, and snippets.

View sfate's full-sized avatar
πŸ‡ΊπŸ‡¦
Glory to Ukraine, Glory to the Nation, fuck the russian federation! :feelsgood:

Oleksii Bobyriev sfate

πŸ‡ΊπŸ‡¦
Glory to Ukraine, Glory to the Nation, fuck the russian federation! :feelsgood:
View GitHub Profile

Setup Mac OS X

I'm in a hospital in Spain and my MacBook was stolen.

Hospital Commit

Now I bought a new one and need to configure it. I have an external hard drive that backup everything using Time Machine, but I don't want all the crap I had in the old one.

1. Run Software Update

# Generate Private Key
$ openssl genrsa -out server.key 2048
# Generate CSR
$ openssl req -new -out server.csr -key server.key -config openssl.cnf
# => Fill in info
# Check CSR
$ openssl req -text -noout -in server.csr
# Sign Cert
$ openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt -extensions v3_req -extfile openssl.cnf
@sfate
sfate / jquery.micro.js
Last active December 17, 2015 04:49 — forked from d33pfri3d/Micro $
Micro version of famous library
var $ = function (d) {
var $ = document.querySelectorAll.bind(document);
Element.prototype.on = Element.prototype.addEventListener;
NodeList.prototype.on = function (event, fn) {
[].forEach.call(this, function (el) {
el.on(event, fn, false);
});
};
@sfate
sfate / README.md
Last active December 17, 2015 02:28 — forked from ngauthier/README.md

Installs ruby-2.0.0-p0 on ubuntu via checkinstall so it's in your package manager and you can remove it.

Quick install:

curl -Lo- https://gist.github.com/Sfate/5535586/raw/install-ruby-2-ubuntu.sh | bash
# Script for installing tmux 1.7
#
# Installation:
# $ curl -Lo- http://git.io/tmux-1.7_install.sh | bash
# Find me here:
# https://gist.github.com/4510955
# exit on error
set -e
var playSingleChime = function()
{
var context = new webkitAudioContext(),
gain = context.createGainNode(),
osc = context.createOscillator();
osc.connect(gain);
gain.connect(context.destination);
osc.frequency.value = 1000.0;
@sfate
sfate / rails.rb
Created October 30, 2012 13:28 — forked from benedikt/rails.rb
Capistrano task to open a rails console on a remote server. Require this file in your deploy.rb and run "cap rails:console"
# encoding: UTF-8
Capistrano::Configuration.instance(:must_exist).load do
namespace :rails do
desc "Open the rails console on one of the remote servers"
task :console, :roles => :app do
hostname = find_servers_for_task(current_task).first
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'"
end
end
@sfate
sfate / gist:3771148
Created September 23, 2012 13:52 — forked from JosephPecoraro/shell-execution.rb
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@sfate
sfate / rspec_rails_cheetsheet.rb
Created September 12, 2012 08:29 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@sfate
sfate / uri.js
Created September 6, 2012 09:41 — forked from nhocki/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"