Skip to content

Instantly share code, notes, and snippets.

# CoffeeScript directive to focus an element when a property changes
# Thanks to: http://stackoverflow.com/questions/14833326/how-to-set-focus-in-angularjs
masterApp.directive "takeFocus", ["$timeout", "$parse", ($timeout, $parse) ->
link: (scope, element, attrs) ->
model = $parse(attrs.takeFocus)
scope.$watch model, (value) ->
if value is true
$timeout ->
element[0].focus()
::
:: Thanks to: https://stackoverflow.com/questions/19832669/inserting-date-time-stamp-in-file-name-using-bat-script/19835038#19835038
::
@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "datestamp=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%"
@francoishill
francoishill / accurev-stat-hist.reg
Created July 8, 2015 12:45
Add explorer right-click entries for Accurev to show `hist` and `stat`
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*]
[HKEY_CLASSES_ROOT\*\AccurevSubCommands]
[HKEY_CLASSES_ROOT\*\AccurevSubCommands\Shell]
[HKEY_CLASSES_ROOT\*\AccurevSubCommands\Shell\Accurev stat]
"MUIVerb"="Accurev stat"
@francoishill
francoishill / golang_benchmark_interface_methods.go
Last active October 2, 2015 03:13
The idea of this benchmark is to determine the performance cost of when we pass around interfaces instead of the concrete struct and getting a field on the struct vs calling a `get` method on the interface
//The idea of this benchmark is to determine the
// performance cost of when we pass around interfaces
// instead of the concrete struct and getting a field
// on the struct vs calling a `get` method on the
// interface
package test
import (
"testing"
@francoishill
francoishill / run_go_app__windows_batch_file.sublime-snippet
Created November 19, 2015 08:49
A snippet to quickly generate a batch file to build/run a go app. In your folder with main.go, just create a new "run.bat" file and trigger this snippet by typing `run_go_app`.
<snippet>
<content><![CDATA[
@echo off
cls
SET ERRORLEVEL=0
echo Running go build... ^
& go build -o "${1:${TM_FILEPATH/.+\/(.+)\/.+\..+/$1/}}.exe"^
& if errorlevel 1 goto ERROR
echo Running exe ${1}.exe... ^
@francoishill
francoishill / README.md
Created December 10, 2015 13:21
Add your ssh key into the `authorized_keys` of CoreOS

On your machine (windows / linux) that you want to get access to from

Setup a (temporary) http server on your machine that always responds with your machine's SSH public key.

Replace the 'YOUR-SSH-KEY-GOES-HERE' if using the golang file of this gist.

On the CoreOS box you want to access

Call these commands below on the CoreOS box by replacing IP-OF-YOUR-MACHINE of your machine having the http server.

@francoishill
francoishill / Basic HTML5.html
Last active December 18, 2015 13:19
Basic HTML5 layout
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body onload="bodyOnload();">
</body>
</html>
angular.module('ng').filter('tel', function () {
return function (tel) {
if (!tel) { return ''; }
var value = tel.toString().trim().replace(/^\+/, '');
if (value.match(/[^0-9]/)) {
return tel;
}
<?php
class Blog extends Eloquent
{
public function images()
{
return $this->has_many_and_belongs_to('Image')
->order_by('blog_image.id', 'asc');
}
}
@francoishill
francoishill / ExpandedExample.cs
Created January 28, 2016 11:38
C# visitor pattern
public abstract class BaseAnimal
{
public abstract void Accept(IAnimalVisitor visitor);
}
public class DogAnimal : BaseAnimal
{
public string MoveHeadStepName = "Dog move head";
public string WagTailStepName = "Dog wag tail";
public string OpenMouthStepName = "Dog open mouth";