Skip to content

Instantly share code, notes, and snippets.

@coderberry
coderberry / cloc_pr.rb
Last active January 30, 2024 15:56
Calculate the diff of a PR
#!/usr/bin/env ruby
# Count lines of code in a pull request
# Usage:
# ./b/cloc_pr 22621
#
# Code: +1212 / -208
# Blank Lines: +241 / -18
# Files: +17 / -0
# Modified Files: 38
@stevenharman
stevenharman / pre-commit.sh
Last active February 22, 2023 12:49
A Git Pre-Commit hook to run the Rubocop static code analyzer. I'm not saying this is a Good Idea™. In fact, it's a Bad Idea™; integrate linting/formatting with your editor/IDE instead. Use at your own risk. If it breaks, feel free to keep both pieces.
#!/usr/bin/env bash
set -eu
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
CLEAR_LINE='\r\033[K'
@hopsoft
hopsoft / db.rake
Last active May 6, 2024 14:00
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@ErikEvenson
ErikEvenson / Vagrantfile
Last active October 22, 2021 23:08
Vagrant config
# This configuration will set up a database (db) and a web server (web) VM.
# Assumes the use of VirtualBox 4.3.14-95030 as a provider.
# Uses vagrant-vbguest plugin (https://github.com/dotless-de/vagrant-vbguest)
# to keep VirtualBox Guest Addition wrangled.
# Configuration
# Machine-specific configuration
DB_INSTALL_SCRIPT = "vagrant_data/db/install.sh"
<!-- How about this?
This is super contrived. It's complex enough, however, to settle some of my concerns about Angular
(or any client-side framework). Basically, I want to see this with as little view logic as possible.
Overview:
A user is dropped into a two-step setup process: 1) account setup, and 2) spending categories setup.
When he completes those two steps, the group of accounts and group of categories should get moved to
a Home screen, where this little problem ends, but hypothetically he begins managing his finances.
@ntreadway
ntreadway / web.js
Created January 30, 2013 19:17
Express server for deploying to Heroku with Angular.
var express = require("express"),
app = express.createServer(express.logger());
port = process.env.PORT || 3000;
app.configure(function(){
app.use(express.methodOverride());
app.use(express.bodyParser());
app.use(express.static(__dirname + '/'));
app.use(express.errorHandler({
dumpExceptions: true,
Vagrant::Config.run do |config|
config.vm.provision :chef_solo do |chef|
chef.add_recipe("apache")
chef.add_recipe("php")
chef.arguments = "-l debug"
end
end
@codef0rmer
codef0rmer / angular-jqueryui-dnd.html
Last active February 22, 2018 10:23
AngularJS + jQueryUI Drag & Drop
<!DOCTYPE html>
<html ng-app="App">
<head>
<meta name="description" content="AngularJS + jQuery UI Drag-n-Drop" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.0.1/angular.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<meta charset=utf-8 />
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@graste
graste / API.md
Created August 22, 2012 19:23 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method: