Skip to content

Instantly share code, notes, and snippets.

View charlesponti's full-sized avatar

Charles Ponti charlesponti

View GitHub Profile
(function($){
var map = {
pickup: 1,
driver: 2,
fare: 3,
car: 4,
city: 5,
payment_method: 6
};
@charlesponti
charlesponti / react-bootstrap-nav.jsx
Last active September 15, 2016 08:57
A ReactJS & Bootstrap Navbar
<nav className="nav navbar navbar-default navbar-fixed-top" role="navigation">
<div className="container-fluid">
<div className="nav-header">
<button className="navbar-toggle collapsed"
type="button" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1">
<span className="sr-only">Toggle navigation</span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
@charlesponti
charlesponti / uninstall_homebrew.sh
Created January 27, 2016 16:54
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@charlesponti
charlesponti / python-cli.sh
Created April 26, 2016 09:13 — forked from nepsilon/3-python-module-you-can-use-on-cli.md
3 Python modules you can use directly on the CLI
# Start a local webserver to serve the file of your current directory on the LAN:
# Python version 2.x:
python -m SimpleHTTPServer
# Python version 3.x:
python3 -m http.server
#Start a local SMTP server to debug your app emails. Emails will be printed on stdout:
python -m smtpd -c DebuggingServer -n
#Parse and prettify a JSON string with:
# load libraries
require 'rubygems' rescue nil
require 'wirble'
#require 'json'
alias q exit
class Object
def local_methods
(methods - Object.instance_methods).sort
@charlesponti
charlesponti / karma.conf.js
Last active December 18, 2015 00:24
Webpack ES2015 Karma with Test coverage
/* eslint-env node */
var path = require('path');
var _ = require('lodash');
var here = require('path-here');
/**
* Current Environment
* @type {string}
*/
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
@charlesponti
charlesponti / Euler-16.rb
Last active December 17, 2015 04:08
Project Euler: Problem 16
def power_sum(base, expo)
num = base
2.upto(expo) { |i| num *= base }
sum = 0
num.to_s.split(//).each { |i| sum += i.to_i }
p sum
end
@charlesponti
charlesponti / Euler_3
Created May 7, 2013 16:58
Project Euler: Problem 3
def is_prime?(num)
2.upto(num-1) { |i| return false if ((num % i) == 0) }
true
end
def largest_prime(num)
primes = []
1.upto(num) { |i| primes << i if num % i == 0 && is_prime?(i) }
p primes.last
@charlesponti
charlesponti / Euler_1
Created May 7, 2013 14:05
Project Euler: Problem 1
def three_five(max)
nums = []
1.upto(max-1) { |i| nums << i if i % 3 == 0 || i % 5 == 0 }
p nums.reduce(:+)
end
@charlesponti
charlesponti / Euler_4
Created May 6, 2013 18:13
Project Euler: Problem 4
def is_palindrome?(num)
num == num.to_s.reverse.to_i ? true : false
end
def palindromatic
range = *(100..999)
results = []
range.each { |i| range.each { |x| results << (i*x) if is_palindrome?(i*x) } }