Skip to content

Instantly share code, notes, and snippets.

View zoras's full-sized avatar
🏠
Working remotely 🌏 Available for Hire

Saroj Maharjan zoras

🏠
Working remotely 🌏 Available for Hire
View GitHub Profile
@dannguyen
dannguyen / corn-stanford-ruby-opencv.sh
Last active August 29, 2015 14:09
How to install rbenv, Ruby 2.1, and the OpenCV gem onto Stanford FarmShare (corn.stanford.edu) without using sudo
# corn.stanford.edu is stuck at Ruby 1.9.3
# This script gets the newest Ruby and lets you install your own gems without sudo
# get rbenv
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
# run the updated .bashrc
source ~/.bashrc
when "email"
regex = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
when "url"
regex = /^(http:\/\/|https:\/\/)?(www.)?[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})([.]?[a-zA-Z]{2})?(\/\S*)?$/i
when "number"
regex = /^\d{1,3}(\,?\d{3})*$/
when "time"
regex = /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/
when "date"
regex = /^(\d{1,2})[\/|-|\.|\s](\d{1,2})[\/|-|\.|\s](\d{2,4})$/
@netshade
netshade / american _why
Created August 24, 2011 18:52
_catch the lucky whiff's tribute to _why
A long, long time ago...
I can still remember
How his blog used to make me smile.
And I knew that if he had his chance
That he could make their code enhance
And, maybe, they’d be happy for a while.
But August made me shiver
With every code line I’d deliver.
Bad news on the doorstep;
@thbar
thbar / fixes.md
Created November 6, 2011 14:00
Getting rid of nokogiri segfaults

This readme is a mixture of everything I read on SO+nokogiri wiki, which ultimately worked out for me.

Here are the steps which worked for me to get rid of segfaults with Nokogiri 1.4.4, on both Lion and Snow Leopard, with Ruby 1.8.7 (patchlevel 334 and +).

First diagnose which version of libxml2 you're using:

bundle exec nokogiri -v

If you have 2.7.3 listed somewhere, you're in bad waters (known to segfault). Install this:

@r00k
r00k / q1.md
Last active March 5, 2016 11:33
Ruby Quiz Question 1

Hello there fine madam or sir!

I have a short quiz for you. It won't take long.

By the way, don't worry if there are questions you can't answer. Lots of people will be struggling along with you, so don't feel bad. You're not alone.

Let's begin!

Do you recognize the method for which this is the (simplified) source?

@matthewmccullough
matthewmccullough / removeignoredtracked.bsh
Created January 20, 2012 19:02
Bash script to remove any ignored files that are accidentally tracked
#!/bin/sh
# Git Remove (from version control) any file that is covered by the ignore patterns and exists on the filesystem. Could be improved to further check the file exists on the git filesystem too.
for eachthing in `git ls-files --others --ignored --exclude-standard`; do if [ -e "$eachthing" ]; then git rm $eachthing; fi; done
@meesterdude
meesterdude / README.md
Last active March 23, 2017 17:42
emoji_spec is a microgem to put emoji in your rspec output.

Emoji Spec

results Tired of the same, dull rspec output? liven it up with some emoji!

Below are the sets presently available, and their corresponding id. if you don't set an ID, one will be randomly chosen every run. Emoji icons may not render in certain terminals.

(pass, fail, pending)

emoji

This bug will track all NEWS items new in Ruby 2.5. This list is based off https://github.com/ruby/ruby/blob/trunk/NEWS.

Only changes relevant to JRuby are listed here. MRI-specific internal changes and features are not included.

NOTE: Pull requests should be done against the ruby-2.5 branch.

Language changes

@kitwalker12
kitwalker12 / config.yml
Created March 7, 2018 22:28
Upgrade Circleci to 2.0 Config
version: 2
jobs:
build:
parallelism: 3
working_directory: ~/foo/bar
docker:
- image: circleci/ruby:2.3-node-browsers
- image: circleci/postgres:9.4
- image: circleci/redis:3.2
- image: circleci/rabbitmq:3.6.6
f = -> x { x + 2 }
g = -> x { x * 2 }
# h is the composition of f and g
h = f >> g
# h is the same as -> x { (x + 2) * 2 }
[1, 2, 3].map(&h) # => [6, 8, 10]
# This is exactly the same as
[1, 2, 3].map(&f).map(&g) # => [6, 8, 10]