Skip to content

Instantly share code, notes, and snippets.

View vinniefranco's full-sized avatar
🏡
WFH

Vincent Franco vinniefranco

🏡
WFH
View GitHub Profile
let mapleader=","
set encoding=utf-8
scriptencoding utf-8
set showmatch
set showmode
set relativenumber
set number
set textwidth=0
set softtabstop=2
let mapleader=","
set encoding=utf-8
scriptencoding utf-8
set showmatch
set showmode
set relativenumber
set number
set textwidth=0
set softtabstop=2
1. Homework
https://blog.codepath.com/2012/11/15/asynchronous-processing-in-web-applications-part-1-a-database-is-not-a-queue
2. Fast PHP-shopish redis worker
https://www.goworker.org/
3. Compatible lib for PHP shops.
https://github.com/spinx/sidekiq-job-php
# When Ruby initializes a program, it instantiates all objects.
#
# This fires your class definitions as if they were methods.
# To illustrate here's an example
class Neat
p 'I am called' # straight to stdout!
# You can dynamically define class constants!
%w(ONE TWO THREE).each_with_index { |const, index| const_set const, index+1 }
end
---
- name: "Setup Vagrant - Ubuntu 12.04 + RBENV + RUBY + POSTGRESQL + GIT"
hosts: vagrant
remote_user: "vagrant"
gather_facts: False
sudo: yes
vars:
#Default shell
- default_shell: /bin/bash
#Default Locale
@vinniefranco
vinniefranco / binary.rb
Created October 30, 2013 08:21
A binary helper for bitwise operations. Outputs: base10, hex, and binary representation of register value. Inputs: Base10: Anything below 999 is read into "register" as a value. Binary: Accepts anything over a half bit. e.g. 0111, 101010, and 1111000, etc. Register can be altered by bit shifting through AND, OR, and XOR operations.
require 'readline'
class String
# colorization
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
" Quick array creation
nmap <leader>ta vF=l<Esc>:s/\%V\S\+/"&",/g<CR>A<BS><Esc>vF=2lgS[JJ:let @/ = ""<CR>
# Tiny ass Luhn CC Check
def valid_luhn_cc? cc
a = i = 0
cc.each_char { |c| ((i%2)==0)? a+=c.to_i : (c.to_i*2).divmod(10).each { |j| a+=j }; i+=1 }
a % 10 == 0
end
function collision_test( obj1, obj2 )
var is_colliding = false;
if ( obj1.x < obj2.x + obj2.w &&
obj1.x + obj1.w > obj2.x &&
obj1.y < obj2.y + obj2.h &&
obj1.y + obj1.h > obj2.y ) {
is_colliding = true;
}
return is_colliding;
}
// Shorter cleaner way to add methods to an object prototype. Thank you Crockford
Function.prototype.method = function ( name, func ) {
if (! this.prototype[name] ) { this.prototype[name] = func; return this; }
};
// And here's the ability to add multiple KVs to objects
Function.method( "methods", function ( obj ) {
if ( typeof obj !== "object" ) return;
for ( var key in obj ) {
if ( ! obj.hasOwnProperty( key ) ) continue;
this.method( key, obj[key] );