Skip to content

Instantly share code, notes, and snippets.

View nogweii's full-sized avatar
🍀

Nogweii nogweii

🍀
View GitHub Profile
@jedi4ever
jedi4ever / puppet-demo.rb
Created December 4, 2011 12:20
using puppet inside ruby
require 'puppet'
require 'pp'
prefix="demo-puppet"
Puppet[:modulepath]=File.join(prefix,"modules")
Puppet[:manifestdir]=File.join(prefix,"manifests")
Puppet[:manifest]=File.join(prefix,"manifests","roles","logger.pp")
#Puppet[:manifest]=File.join(prefix,"manifests","site.pp")
code="import '#{Puppet[:manifest]}'\n"
@rstacruz
rstacruz / index.md
Last active August 2, 2025 18:42
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@uriel1998
uriel1998 / volume.rb
Created February 10, 2012 17:55 — forked from jaspervdj/volume.rb
Set PulseAudio volume, mute, unmute, and change default sink (and automagically switch running audio streams) from the commandline
#!/usr/bin/ruby
#
# Moved to: https://github.com/uriel1998/volumerb
#
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
# Unported License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-sa/3.0/.
#
# Forked/derived from original by Jasper Van der Jeugt (jaspervdj);
@ChuckJHardySnippets
ChuckJHardySnippets / string_ext.rb
Created March 8, 2012 11:40 — forked from erskingardner/string_ext.rb
Ruby: Convert String to Boolean
class String
def to_bool
return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end
end
@slim
slim / macgen.c
Created April 16, 2012 20:33
Random MAC address generator
/* Random MAC address generator.
Orignal code written by http://www.hypervivid.com/.
Code modified by Jeffrey Leung e-mail: [email protected].
This software is distrubited under the GNU/GPL open source licensce.
Please note: This software comes in "AS-IS" basis, therefore there is no
guarantee in this program's proper function.
Any modifications are welcome.
*/
#include <stdio.h>
#include <stdlib.h>
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@sirhc
sirhc / jury-mojo.pl
Created April 28, 2012 23:13
Automatically check jury duty on-call status
#!/usr/bin/env perl
#
# A simple script to repeatedly check on-call status for United States
# District Court juror instructions. It will send mail with any instructions
# and, if necessary, schedule itself to check again when instructed.
#
# Usage: /path/to/jury-mojo.pl PARTICIPANT_ID ZIP_CODE
use 5.012;
use Mojo::UserAgent;
@surrealist
surrealist / log2.txt
Created June 10, 2012 14:10
What has happened in .git folder Part 2 (status, branch, checkout)
(Continued from part 1: https://gist.github.com/2905683)
In this 2nd try,
I had monitored git folder while run these following commands:
C:\git\test> git status
C:\git\test> git branch b1
C:\git\test> git checkout b1
C:\git\test> git add readme.txt
C:\git\test> git commit -m "readme"
@jotto
jotto / google_oauth2_access_token.rb
Created June 14, 2012 21:15
ruby command line script for generating google oauth2 access token
# (create oauth2 tokens from Google Console)
client_id = ""
client_secret = ""
# (paste the scope of the service you want here)
# e.g.: https://www.googleapis.com/auth/gan
scope = ""
@ndarville
ndarville / secret-key-gen.py
Created August 24, 2012 17:01
Generating a properly secure SECRET_KEY in Django
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`