Skip to content

Instantly share code, notes, and snippets.

View kreas's full-sized avatar
:shipit:
Heathen

Tim Warren kreas

:shipit:
Heathen
View GitHub Profile
(function(){
function multiply_by_two(num){
if (typeof num === 'number'){
return num * 2;
} else {
return num + ' is not a valid number';
}
}
// If the value is equal write '.' to the page if not write 'F'
package com.company;
import java.util.Arrays;
public class Main extends TestCase {
static public void main(String[] args) {
// Assessment 0: Multiples of 3 and 5 in n
assertEqual(multiplesOf3And5(1000), 233168);
assertEqual(multiplesOf3And5(500), 0);
library form;
import 'dart:html';
class Form {
static String formType = window.location.hash.replaceFirst('#', '');
Form(){
importForm(formType);
}
@kreas
kreas / gist:6455780
Created September 5, 2013 20:34 — forked from afeld/gist:5704079

This was tested using Ruby 2.0.0 and Rails 4.0.0.rc1.

Bower

  1. Set the install directory for Bower components:

    // .bowerrc
    {

"directory": "app/assets/components"

@kreas
kreas / gist:5529020
Last active December 17, 2015 01:29
Super simple form validation. **Requires jQuery and Underscore**
required_fields = $('[required="required"], .required')
$('.validate').click () ->
validate_form()
if $('.input-error').length == 0
$('form').submit()
false
required_fields.blur () ->
validate_input(@)

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods

Header 1
h2. Header 2
h3. Header 3
h4. Header 4
h5. Header 5

This is a paragraph, which is text surrounded by whitespace. Paragraphs can be on one
line (or many), and can drone on for hours. “Quotes” and ‘quotes’ are handled
nicely—as are dashes and such.

markdown reference

footnotes:

works in tumblr with markdown editor enabled
requires multimarkdown

input:
sentence with footnote[^1].

@kreas
kreas / etc_init.d_unicorn_example.co.uk
Created December 5, 2012 16:48 — forked from rubysolo/etc_init.d_unicorn_example.co.uk
Ruby on Rails server setup on Ubuntu 11.04 with Nginx, Unicorn, Rbenv
#! /bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
@kreas
kreas / gist:3719847
Created September 14, 2012 04:45
Set the default date format in Rails 3
#environment.rb
Date::DATE_FORMATS.merge!(:default => "%m/%d/%Y")