Skip to content

Instantly share code, notes, and snippets.

Avatar

edgarjs edgarjs

  • www
View GitHub Profile
@edgarjs
edgarjs / makeswap.sh
Created Mar 23, 2016
Make a 4G swap
View makeswap.sh
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo echo '/swapfile none swap sw 0 0' >> /etc/fstab
sudo echo 'vm.swappiness=10' >> /etc/sysctl.conf
sudo echo 'vm.vfs_cache_pressure=50' >> /etc/sysctl.conf
View pencil-light.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGKSpYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKcHCBMXGyImVSRudWxs1QkKCwwNDg8QERJcTlNDb21wb25lbnRzVU5TUkdCXE5T
Q29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NPECgwLjE3MjU0OTAx
OTYgMC4xNzI1NDkwMTk2IDAuMTcyNTQ5MDE5NiAxTxAnMC4xNDczOTIwNjQzIDAuMTQ3
@edgarjs
edgarjs / example.rb
Created May 12, 2015
serialize dirty behavior 4.2.0 vs 4.2.1
View example.rb
class Person < ActiveRecord::Base
serialize :something, Hash
end
# rails 4.2.0
Person.last.changes # => { "something" => [{}, {}] }
# rails 4.2.1
Person.last.changes # => {}
@edgarjs
edgarjs / default_job_options.rb
Created Jan 23, 2015
Default values and custom type handling before queuing a job. Just include this module in your ActiveJob class
View default_job_options.rb
module DefaultJobOptions
extend ActiveSupport::Concern
included do
before_enqueue do |job|
job.scheduled_at ||= 10.seconds.from_now.to_f
job.arguments = job.arguments_with_safe_types
end
end
View keybase.md

Keybase proof

I hereby claim:

  • I am edgarjs on github.
  • I am edgarjs (https://keybase.io/edgarjs) on keybase.
  • I have a public key whose fingerprint is 423D 8E24 1953 473C 1D6D FE70 E16E 91CB D2AD 1194

To claim this, I am signing this object:

View socket.io.osx.podspec
Pod::Spec.new do |s|
s.name = "socket.IO"
s.version = "0.4.1"
s.summary = "socket.io v0.7.2+ for iOS devices."
s.description = <<-DESC
Interface to communicate between Objective C and Socket.IO with the help of websockets. It's based on fpotter's socketio-cocoa and uses other libraries/classes like SocketRocket, json-framework (optional) and jsonkit (optional).
DESC
s.homepage = "https://github.com/pkyeck/socket.IO-objc"
s.license = 'MIT'
@edgarjs
edgarjs / bypass.rb
Created Jun 13, 2013
How to bypass validations
View bypass.rb
class User < ActiveRecord::Base
validates_presence_of :email
validates_uniqueness_of :email
end
User.create(email: 'foo@bar.com')
@user = User.new
@user.save # => false
@user.update_attribute(:email, 'foo@bar.com') # => true