Skip to content

Instantly share code, notes, and snippets.

@ChunkRadius
ChunkRadius / gulpfile.js
Created November 24, 2014 11:05
Uploading files via sftp using Gulp
var gulp = require("gulp"),
sftp = require("gulp-sftp"),
path = require("path"),
changed = require("gulp-changed"),
rename = require("gulp-rename"),
tap = require("gulp-tap"),
notify = require("gulp-notify"),
remoteBaseDir = "/base/dir/on/server",
watchedFilesToUpload = ["css/**/*.css", "js/**/*.js"];
@ChunkRadius
ChunkRadius / pay_invoice.php
Created May 28, 2015 16:16
Capture Invoice Payment Gist
// Make sure user has card on file.
if (empty($user['cclastfour'])) {
$config['vars']['nocard'] = true;
$config['vars']['error'] = 'You do not have any payment methods on file';
return $config;
}
$payment = localAPI('capturepayment', ['invoiceid' => $invoice_id], 'admin');
if ($payment['result'] === 'success') {
$config['vars']['payment']['success'] = sprintf('Payment succeeded');
@ChunkRadius
ChunkRadius / gist:6ef1c7330816e4281e23
Created July 21, 2015 14:53
AngularJS Input Directive Formatters
"use strict";
/**
* @description A simple formatter for <input type="checkbox"> fields.
* @usage <input type="checkbox" ng-model="myCheckbox" boolean>
*/
angular.module("clls").directive("boolean", function() {
return {
require: "ngModel",
link: function(scope, element, attrs, ngModel) {
@ChunkRadius
ChunkRadius / notZero.js
Last active September 27, 2016 08:15
A simple AngularJS directive to make sure a number is not zero. It sets the formName.elementName.$error.zero value accordingly.
/**
* @description A simple check to ensure a number is not zero. Sets the "zero" validation accordingly.
* @usage <input ng-model="myModel" not-zero>
*/
angular.module("app").directive("notZero", function() {
var linkFunc = function(scope, element, attrs, ngModel) {
var zeroValidator = function(value) {
var num = parseFloat(value);
@ChunkRadius
ChunkRadius / demo.js
Created August 18, 2015 08:33
New alertify transtions (demo in AngularJS)
<!DOCTYPE html>
<html ng-app="testApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
.container {
position: fixed;
bottom: 0;
@ChunkRadius
ChunkRadius / IMPORT.md
Created August 21, 2015 14:08
CLLS Import Logic

This is an overview of the logic implemented in Import.php for external review.

Application (Period 3)

Returns data from previous year's Revised Budget for all forms.

Revised Budget (Period 4)

angular.module('chargeback', ['ui.router', 'upload', 'ngAnimate'])
// Lots of code before the directive...
.directive('test', ['$filter', function($filter){
// This should handle and input and return 0 or a valid float.
function toFloat(val){
var f = parseFloat(val || 0)
return isFinite(f) ? f : 0;
}
// This file is correct version, but is not built dev_appserver because of a
// bug in the SDK.
// +build !appengine
package broker
import (
"encoding/json"
"errors"

Keybase proof

I hereby claim:

  • I am bradberger on github.
  • I am bradberger (https://keybase.io/bradberger) on keybase.
  • I have a public key whose fingerprint is 077F FE20 030D 6133 D806 AFBB ECCA B1EF 2B12 7003

To claim this, I am signing this object:

@ChunkRadius
ChunkRadius / md5-example.go
Created January 2, 2017 13:55
Golang - How to hash a string using MD5
package main
import (
"fmt"
"crypto/md5"
)
func GetMD5Hash(s string) string {
return fmt.Sprintf("%x", md5.Sum([]byte(s)))
}