Skip to content

Instantly share code, notes, and snippets.

@LoganBarnett
LoganBarnett / .bash_profile
Last active August 29, 2015 14:08
Misc nifty bash profile settings
# standard ls colors
alias ls="ls -G"
# grep highlights your search matches
alias grep="grep --color=auto"
# makes the prompt show exit code, sends an alert (beep), shows the time the prmopt was shown, and the current path. $ is on the next line.
# also colored pink to make easier to spot
export EXIT_STATUS_VAR='$?'
export PS1="\[\e[35m\]\a$(echo $EXIT_STATUS_VAR):\j*\@ \u@\h \w\n\$ \[\e[0m\]"
export PS2=""
@LoganBarnett
LoganBarnett / make_guid.coffee
Last active August 29, 2015 14:08
Coffeescript GUID generator
makeGuid = () ->
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) ->
r = Math.random() * 16 | 0
if c == 'x'
v = r
else
v = r = (r&0x3|0x8)
return v.toString(16)
)
Maybe<Email, Exception> UpdateEmail(Maybe<Email, Exception> m) {
m = ValidateEmail(m);
m = UpdateUserEmail(m);
m = SendVerificationEmail(m);
return m;
}
@LoganBarnett
LoganBarnett / three-adapter.js
Last active August 29, 2015 14:20
Logan's flailing re: a scene adapter using FP
const move = (obj) => {
if(obj.moving) {
const newLocation = new Vector3(
obj.transform.x + obj.speed.x
, obj.transform.y + obj.speed.y
, obj.transform.z + obj.speed.z
);
var newTransform = new Transform(obj.transform, {location: newLocation}) * Time.delta});
return new SceneObj(obj, {transform: newTransform});
}
@LoganBarnett
LoganBarnett / hellplusplus.cpp
Last active August 29, 2015 14:23
Post incremental hell
int foo = 0;
int bar = foo++;
print(foo); // <= ?
print(bar); // <= ?
// 5,000,000 ints of 10
std::vector<int> stuff(5000000, 10);
// do you know what's in the var 'it'? Is it safe to copy lots and lots?
for (std::vector<int>::iterator it = stuff.begin(); it != stuff.end(); it++) {
@LoganBarnett
LoganBarnett / promises_and_partial.js
Created June 25, 2015 22:57
Usage of partial application.
var getMdmCodes = function() {
var requests = [
service.getProductGroupCodes
, service.getProductTypeCodes
, service.getStatusCodes
, service.getCountryCodes
, _.partial(service.getParties, 'shipper')
, _.partial(service.getParties, 'consignee')
, _.partial(service.getTariffPointsForUser, {tariffPointType: 'origin'})
, _.partial(service.getTariffPointsForUser, {tariffPointType: 'destination'})
@LoganBarnett
LoganBarnett / gulpfile.js
Last active August 29, 2015 14:26
Gulpfile for hosting some standard static assets
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var DIST = 'dist';
@LoganBarnett
LoganBarnett / translation_test.js
Last active August 29, 2015 14:26
Finds templates, scans for things that are obviously not translated and builds a report with a failed test.
it("check for untranslated strings", function() {
// WIP for the new version
const textRegexp = /.+/;
const templateBindingRegexp = /^({{.+}})$/;
const results = _.map(tmplArray, $tc.get) // load the template from the path
.map(angular.element) // process the template data into Angular's DOM
.map((e) => e.text()) // remove all markup - only text should remain
.map((t) => t.trim()) // remove whitespace
// strip out bindings - they are dynamic and thus translated. Probably.
.map((t) => t.replace(templateBindingRegexp, ''))
class CallView < ApplicationView
set_java_class 'call.CallFrame'
CONTRACT_TYPE_TRANSLATION = {nil => nil, '' => '', 'Current' => 'Current', 'current' => 'Current'}
#customer fields
map :view => "customer_name_combo_box.selected_item", :model => :customer_name, :ignoring => :action
map :view => "customer_name_combo_box.model", :transfer => :customer_names, :using => [:to_combo_box_model, nil]
map :view => "contact_name_text_field.text", :model => :contact_name
map :view => "address_text_field.text", :model => :street_address
NativeException: java.lang.reflect.InvocationTargetException: null
java/awt/EventQueue.java:853:in `invokeAndWait'
javax/swing/SwingUtilities.java:1257:in `invokeAndWait'
sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke'
sun/reflect/DelegatingMethodAccessorImpl.java:25:in `invoke'
java/lang/reflect/Method.java:585:in `invoke'
org/jruby/javasupport/JavaMethod.java:298:in `invokeWithExceptionHandling'
org/jruby/javasupport/JavaMethod.java:278:in `invoke_static'
org/jruby/java/invokers/StaticMethodInvoker.java:47:in `call'