Skip to content

Instantly share code, notes, and snippets.

View marianposaceanu's full-sized avatar

Posăceanu Marian marianposaceanu

View GitHub Profile
{
# First, we need to add an empty key/value tuple (just an empty fork) to this `execution`, in preperation for
# making a `locals` list to store variables on.
#
# ┌ - we have to assume that native juxtaposition of `infrastructure` against the root-level `execution` will
# │ somehow “fall through.” I haven’t yet figured out the semantics of Nuclear-level scoping/fall-through.
# │ - considering: if `<this> locals` nothingnesses-out, then we juxtapose against enclosing scope at the
# │ interpreter level (which would imply, at this root scope, juxtaposing against the global scope I suppose)
# │
# │ ┌ - no `call()` implemented at this level, so we have to assume that the native-default juxtaposition for
@marianposaceanu
marianposaceanu / results.md
Last active January 1, 2016 11:49
StandardSingleton vs MethodMissingSingleton

Benchmark results

Ruby 2.1.0

                               user     system      total        real
StandardSingleton:         0.141000   0.000000   0.141000 (  0.129891)
MethodMissingSingleton:    0.125000   0.000000   0.125000 (  0.130870)
@marianposaceanu
marianposaceanu / closures.rb
Created December 27, 2013 00:24
CLOSURES IN RUBY by Paul Cantrell
# CLOSURES IN RUBY Paul Cantrell http://innig.net
# Email: username "cantrell", domain name "pobox.com"
# I recommend executing this file, then reading it alongside its output.
#
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments,
# then trying to guess the output of the code!
# A closure is a block of code which meets three criteria:
#
@marianposaceanu
marianposaceanu / arel mapped template ids.rb
Created December 21, 2013 00:12 — forked from ndbroadbent/arel mapped template ids.rb
Using Arel instead of ActiveRecord
module Sq
class Template < Sequel::Model
one_to_many :fields
def mapped_template_ids
FieldMapping.as(:m).
join(Field.named(:f), id: :field_id, template_id: id).
join(Field.named(:mf), id: :m__mapped_field_id).
distinct.select_map(:mf__template_id)
end
@marianposaceanu
marianposaceanu / quick_ruby_tips.md
Last active December 29, 2015 05:19
Quick, no fuss Ruby tips.

How to Find Where Ruby Methods are Defined

method(:page_title).source_location

# => ["/Users/ben/.rvm/gems/ruby-2.0.0-p353/gems/flutie-1.3.3/app/helpers/page_title_helper.rb", 2]
@marianposaceanu
marianposaceanu / sudo_no_password.md
Last active December 27, 2015 12:48
Simple way to run stuff like `sudo shutdown` without entering a password

Run sudo commands without entering a password

Simple way to run stuff like sudo shutdown without entering a password.

Tip: do not use this in production, I use it to shutdown my VMs when I'm done working

  1. run: sudo EDITOR=vim visudo
  2. add a new group, let's say named noners : %noners ALL=(ALL) ALL
  3. run: sudo vim /etc/sudoers.d/g_noners
  4. let's say the user you want to run sudo without password is marian then just add:
@marianposaceanu
marianposaceanu / data_sample.coffee
Last active December 25, 2015 13:29
It uses tri-grams to do a quick fuzzy like search.
data_sample = [
name: "Mrianescu"
coords: [0, 0]
,
name: "Marianescu"
coords: [0, 0]
,
name: "Marian"
coords: [0, 0]
,

Faster specs

Add to Gemfile into test and development groups:

gem 'perftools.rb', require: 'perftools'

From the command line:

@marianposaceanu
marianposaceanu / linux_fun.md
Last active January 29, 2023 20:31
How to have some fun using the terminal.

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!
module KawaiiPhrase
# Makes awesome random phrases such as "Enjoyable Green Turtle"
ADJ_1 = [
'epic',
'tasty',
'shiny',
'mega',
'ultra',
'hyper',