Skip to content

Instantly share code, notes, and snippets.

View svenyurgensson's full-sized avatar

Yury Batenko svenyurgensson

View GitHub Profile

Migrating from Mongoid 4.x.x to Mongoid 5.x.x in Ruby on Rails app

Config changes in mongoid.yml

All configuration options can be found on the MongoDB Docs

Rename sessions to clients

Was

production:
  sessions:
@svenyurgensson
svenyurgensson / sync-postgres-mina.rb
Created June 10, 2016 12:45 — forked from nicolai86/sync-postgres-mina.rb
sync down the content of a postgresql database used by a rails application using mina.
RYAML = <<-BASH
function ryaml {
ruby -ryaml -e 'puts ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[key] }' "$@"
};
BASH
namespace :sync do
task :db do
isolate do
invoke :environment
/* Colors */
.red {color:#A3293D!important}
.pink{color:#FD9FC1!important}
.salmon{color:rgba(253, 160, 150, 1)!important}
.lgreen{color:#A9D12B!important}
.green{color:#748A30!important}
.teal {color:#07AB8F!important}
.sky {color:#76C6F3!important}
.skyblue {color:#43A4EF!important}
@svenyurgensson
svenyurgensson / db.rake
Created February 25, 2016 04:55 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd

Minecraft Ultimate Tool Set

Requires creative mode or operator power on a multiplayer server. On a single player game (survival or hardcore), you will need "cheats" enabled to move into creative mode. Don't forget to leave creative mode when done.

These items might be stupid. Be prepared to repair the country-side.

@svenyurgensson
svenyurgensson / crypto-wrong-answers.md
Created November 26, 2015 08:11 — forked from paragonie-scott/crypto-wrong-answers.md
An Open Letter to Developers Everywhere (About Cryptography)

Keybase proof

I hereby claim:

  • I am svenyurgensson on github.
  • I am jurbat (https://keybase.io/jurbat) on keybase.
  • I have a public key whose fingerprint is 5679 8C14 1A32 3C3A 1933 48B9 9D8D 9FB7 D6B6 0785

To claim this, I am signing this object:

self.addEventListener('fetch', async (event) => {
const response = await fetch(event.request);
const cache = await caches.open('cache-v1');
if (response.ok === true) {
cache.put(event.request, response);
event.respondWith(response);
} else {
event.respondWith(cache.match(event.request));

System

  1. Set up iCloud Keychain
  2. Remove icons and hide Dock
  3. Default address in iMessage
  4. Install Updates
  5. Add Ru Input Sources
  6. Set up Shortcuts
  7. Add text shortcuts Text
@svenyurgensson
svenyurgensson / functions.js
Last active August 29, 2015 14:25 — forked from RedBeard0531/functions.js
Min, Max, Sum, Count, Avg, and Std deviation using MongoDB MapReduce
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
function map() {
emit(1, // Or put a GROUP BY key here
{sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count:1,
diff: 0, // M2,n: sum((val-mean)^2)
});