Skip to content

Instantly share code, notes, and snippets.

View lightyrs's full-sized avatar
🌒
ლ(▀̿̿Ĺ̯̿̿▀̿ლ)

Harris Novick lightyrs

🌒
ლ(▀̿̿Ĺ̯̿̿▀̿ლ)
View GitHub Profile
@lightyrs
lightyrs / force-utf8.rb
Created March 12, 2015 06:01
really force utf-8 in ruby
line.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
@lightyrs
lightyrs / _pm_irbrc.rb
Created May 6, 2012 20:37 — forked from inkdeep/_pm_irbrc.rb
Useful method to print an objects methods in an irb/console session.
# pm - Print methods of objects in irb/console sessions.
# Goes in ~./irbrc
#
begin # Utility methods
def pm(obj, *options) # Print methods
methods = obj.methods
methods -= Object.methods unless options.include? :more
filter = options.select {|opt| opt.kind_of? Regexp}.first
methods = methods.select {|name| name =~ filter} if filter
@bububa
bububa / gist:3607104
Created September 3, 2012 06:02
reset ulimit
# vi /etc/security/limits.conf
[Modify or add "nofile" (number of file) entries - note
that a userid can be used in place of *]
* soft nofile 64000
* hard nofile 64000
# vi /etc/pam.d/login
[Add the line]
session required /lib/security/pam_limits.so
@mkelley33
mkelley33 / mkelley33-pryrc.rb
Last active December 17, 2015 12:29
My .pryrc
# encoding: UTF-8
Pry.config.editor = "vim"
Pry.config.pager = false
Pry.config.commands.alias_command "lM", "ls -M"
if defined?(Encoding) then
Encoding.default_external = 'utf-8'
Encoding.default_internal = 'utf-8'
else
$KCODE = 'utf-8'
@lightyrs
lightyrs / combining-ar-scopes-with-or.md
Last active February 25, 2016 05:55
Incrementally Building the v1/events_controller#index Query

Combining ActiveRecord Scopes with OR [<v5]

This came about while trying to construct an ActiveRecord query.

via http://stackoverflow.com/a/9540911/111363

Note that merge combines WHERE clauses using AND. While ActiveRecord does not currently have the ability to combine relations using OR instead, it is coming in ActiveRecord 5 (https://github.com/rails/rails/commit/9e42cf019f2417473e7dcbfcb885709fa2709f89).

It'll look something like this:

via http://tombroomfield.com/the-upcoming-active-record-or-method-will-clean-up-your-queries/

@lightyrs
lightyrs / Custom.css
Created December 17, 2012 08:26
My Chrome Dev Tools Skin incorporates the sleek visual style of codepen.io with some of my own usability enhancements. Pictured here with Monokai color scheme ( http://imgur.com/mbrqt ).
/*
Chrome Developer Tools - Monokai Color Theme
Author: Béres Máté Csaba / bjmatt.com / @bjmatt / beres.mate@bjmatt.com
-----------------------------------------------------------------------------------------------------------
Installation:
1. Find your Chrome's user stylesheets directory:
@lightyrs
lightyrs / favorites.css
Last active March 30, 2017 01:16
Favorite Simple CSS Styles
.subtle-gradient-1 {
background-image: linear-gradient(to right, #f0fcff 0%, #f2f4ff 100%);
}
.pastel-gradient-1 {
background-image: linear-gradient(to left bottom, hsl(253, 100%, 85%) 0%, hsl(132, 100%, 85%) 100%);
}
@nhance
nhance / method_logger.rb
Created September 6, 2012 12:58
Rails compatible method logging. Use this to log all calls to instance methods of a class to the log.
Model.new.foo
@jirikolarik
jirikolarik / video_uploader.rb
Last active November 15, 2018 18:26
CarrierWave FFmpeg Uploader example
class VideoUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::FFmpeg
RESOLUTIONS = [
{ version: :p1080, resolution: '1920x1080'},
{ version: :p720, resolution: '1280x720'}
]
# Choose what kind of storage to use for this uploader:
@asimihsan
asimihsan / r_tutorial.md
Last active November 10, 2019 18:00
R tutorial

R tutorial

Introduction

R is a software environment for statistical computing and graphics. The kinds of things people do in R are:

  • Plot charts,
  • Create and evaluate statistical models (linear, nonlinear),
  • Perform statistical analyses (tests, classification, clustering).