Skip to content

Instantly share code, notes, and snippets.

View qguv's full-sized avatar
vibing

Quint Guvernator qguv

vibing
View GitHub Profile
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@rcoup
rcoup / loggly.py
Created September 12, 2012 02:17
Loggly CLI interface - standalone (Just Python). Pages results automatically so you can easily grab >2000 rows.
#!/usr/bin/env python
"""
Loggly CLI interface - standalone (Just Python). Deals with paging results automatically so you can easily grab >2000 rows.
Run `loggly.py --help` to see usage information.
TODO:
* Support XML format results (ie. combining multiple pages of results together)
* Facet support
@kamiaka
kamiaka / convert_kana.js
Last active August 3, 2023 03:50
JS Convert "Kana" one from another (zen-kaku, han-kaku and more)
/**
* Convert "Kana" one from another
* (zen-kaku, han-kaku and more)
*
* @param string str
* @param string option (optionaly)
* @return string converted string
*/
function convert_kana (str, option) {
option = option || "KV";
@wilbowma
wilbowma / jail.pl
Last active August 1, 2022 11:16
A perl script to create nginx chroot in arch linux.
#a/usr/bin/perl
# This script was hastily cobbled together for my own use. It can
# probably break your system. Use at your own risk.
$JAIL = "/srv/http";
$USER = "http";
$GROUP = "http";
$WWW_DIR = "www";
sub run{
@termi
termi / crossBrowser_initKeyboardEvent.js
Last active June 13, 2023 02:01
Cross-browser initKeyboardEvent
void function() {//closure
var global = this
, _initKeyboardEvent_type = (function( e ) {
try {
e.initKeyboardEvent(
"keyup" // in DOMString typeArg
, false // in boolean canBubbleArg
, false // in boolean cancelableArg
, global // in views::AbstractView viewArg
@quchen
quchen / trolling_haskell
Last active February 24, 2024 01:30
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
@EEVblog
EEVblog / Arduino-IR-TX-NEC
Last active January 25, 2023 20:59
A simple Arduino driver for the NEC (Japanese) Infrared IR protocol. Drive an IR LED direct with your own code. This is a direct pin bit-bang approach, so beware about interrupts and timing difference between hardware. Feel free to use hardware PWM to generate the carrier frequency if you want better accuracy.
//*****************************************
// NEC (Japanese) Infrared code sending library for the Arduino
// Send a standard NEC 4 byte protocol direct to an IR LED on the define pin
// Assumes an IR LED connected on I/O pin to ground, or equivalent driver.
// Tested on a Freetronics Eleven Uno compatible
// Written by David L. Jones www.eevblog.com
// Youtube video explaining this code: http://www.youtube.com/watch?v=BUvFGTxZBG8
// License: Creative Commons CC BY
//*****************************************
@tparton42
tparton42 / keypress_position.js
Created December 6, 2013 04:32
Getting the cursor position of a keypress in JavaScript
$('alphaonly').keypress(function(e){
// Convert the character code to a string
var strIn = String.fromCharCode(e.charCode);
// The current cursor position is stored as: e.target.selectionStart
if(e.target.selectionStart == 0) {
// Setup our pattern, excluding anything other than a-zA-Z
var patt = /[a-zA-Z]/gi;
} else {
// Setup our pattern to allow alpha, spaces and dashes
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results