Skip to content

Instantly share code, notes, and snippets.

View FrancoB411's full-sized avatar

Franco Barbeite FrancoB411

View GitHub Profile
@FrancoB411
FrancoB411 / FizzBuzzPlus.js
Created March 1, 2012 00:01
FizzBuzzPlus CodeYear Challenge
//FizzBuzzPlus Challenge from CodeYear
var FizzBuzzPlus = { //create an object called FizzBuzzPlus
isFizzBuzzie: function(num) { // Create function isFizzBuzzie with one argument: an integer
if(num % 3 === 0 && num % 5 === 0) { // return false if the provided integer is a multiple of both 3 and 15
return false;
}
else if ( num % 3 === 0 || num % 5 === 0) { //return true if the provided integer is a multiple of 3 or 15 (not both)
@FrancoB411
FrancoB411 / FizzBuzz,rb
Created March 7, 2012 06:58
Fizzbuzz that also calls out prime numbers, by extending the Fixnum class with a .prime? method.
#extends Fixnum class with prim? method. usage ex: 5.prime?
#returns a boolean
class Fixnum
def prime?
('1' * self) !~ /^1?$|^(11+?)\1+$/
end
end
@FrancoB411
FrancoB411 / FizzbuzzRecursive.js
Created March 20, 2012 04:49
Fizzbuzz with recursion instead of a loop.
function fizzbuzz(num) {
if(num === 0) { //base case
return 1;
}if(num < 0) { //termination case
return console.log("Positive numbers only, please.");
}if((num % 3 === 0) && (num % 5 === 0)) { //fizzbuzz conditionals
console.log("fizzbuzz");
@FrancoB411
FrancoB411 / Blackjack.js
Created March 28, 2012 08:42
Blackjack game from week 12 of CodeYear
function Card(suit, num) {
var cardSuit = suit;
var cardNum = num;
this.getNumber = function() {
return cardNum;
};
this.getSuit = function() {
return cardSuit;
};
this.getValue = function() {
@FrancoB411
FrancoB411 / randomness_threshold.rb
Last active October 7, 2015 00:58
Method returns a random result based on the probability threshold passed in.
# returns true N percent of the time.
# pass in a threshold number N from 1-100
def random_threshold (percentage)
# number_pool of 100 numbers.
number_pool = (1..100).to_a
# return true if random number_pool sample is below threshold N.
number_pool.sample < percentage ? true : false
end
@FrancoB411
FrancoB411 / blockly_test_app.js
Created August 1, 2012 18:16
Simple test app, goofing around with google blockly.
var no;
var name2;
var yes;
var gender;
var so;
var comma;
var iscool;
var invitationQuestion;
function convo() {
name2 = window.prompt('please enter your name');
@FrancoB411
FrancoB411 / snippets.js
Last active October 10, 2015 18:47
Snippets
//JS
//===============================================================================
//Modal centering Script:
$('#YourModal').modal().css(
{
'margin-top': function () {
return window.pageYOffset-($(this).height() / 2 );
}
@FrancoB411
FrancoB411 / .gitconfig
Created September 18, 2012 22:10
Useful gitconfig aliases
[alias]
co = checkout
st = status
rso = remote show origin
# e.g. git graphviz --first-parent master | dotty /dev/stdin
graphviz = "!f() { echo 'digraph git {' ; git log --pretty='format: %h -> { %p }' \"$@\" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g' ; echo '}'; }; f"
# Pretty log
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
# Print out all commits whose hash starts with a given string
abbr = "!sh -c 'git rev-list --all | grep ^$1 | while read commit; do git --no-pager log -n1 --pretty=format:\"%H %ci %an %s%n\" $commit; done' -"
@FrancoB411
FrancoB411 / gist:3757824
Created September 20, 2012 19:22 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@FrancoB411
FrancoB411 / .bashrc heart prompt
Last active December 16, 2015 06:09
my .bashrc with custom prompt
### Add RVM to PATH for scripting
PATH=$PATH:$HOME/.rvm/bin
### Add bin to my PATH
PATH=$HOME/bin:$PATH
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"