Skip to content

Instantly share code, notes, and snippets.

View marianposaceanu's full-sized avatar

Posăceanu Marian marianposaceanu

View GitHub Profile
@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 March 16, 2025 22: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',
# Rails 4
class AddHstoreIndexes < ActiveRecord::Migration
def change
add_index "nodes", "properties", using: :gin
end
end
# Rails 3.x

Basic git tips

Issue with missing tracked files
git update-index --assume-unchanged my-tracked-file-that-is-awol
git status -u --ignored
git update-index --no-assume-unchanged my-tracked-file-that-is-awol
@marianposaceanu
marianposaceanu / vim_tips.md
Last active December 20, 2015 05:29
Just random VIM tips

VIM Tips

Record a sequence

Use q + [lowercase letter to name the macro] then do stuff and when done q and @a or 22@a to repeat.

Advanced search and replace

s:url("../images/\(.*\)");:url("<%= asset_path '\1' %>");:gi

Basic Rails security tips

Secret tokens in version control

# in config/initializers/secret_token.rb

MySite::Application.config.secret_token = ENV['SECRET_TOKEN']