Skip to content

Instantly share code, notes, and snippets.

@bernos
bernos / Aus mobile validator
Created April 15, 2011 00:51
Validates a number is a valid australian mobile
function(value) {
return String(value).match(/^04[0-9]{8}$/) != null;
}
@bernos
bernos / index-with-amd.html
Created February 8, 2012 03:53
A javascript module template which supports an AMD loader (like requirejs) when available, but fails over to adding the module to a specified root context when an AMD loader is not available.
<!doctype html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<script data-main="main-with-amd" src="requirejs-1.0.4.min.js"></script>
</body>
</html>
@bernos
bernos / hack.sh
Created March 31, 2012 23:09 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@bernos
bernos / gist:2772790
Created May 23, 2012 01:47
Add svn props to existing files from bash
find . \( -name "*.php" -o -name "*.js" \) -exec svn propset svn:keywords Id {} \;
@bernos
bernos / grunt.js
Created June 16, 2012 04:44 — forked from johnkpaul/gist:2361303
gruntjs Mocha task
module.exports = function(grunt) {
grunt.initConfig({
mocha : {
all : {
src : 'test/**/*.js', // path to test.js files
options : {
globals : ['piewpiew'],
ui : 'tdd',
reporter : 'spec'
@bernos
bernos / ExampleController.cs
Created October 21, 2013 08:35
ASP.net MVC4 paginated lists
public virtual ActionResult Index(int page = 1, int pageSize = 10)
{
var work = UnitOfWork();
int total;
if (pageSize > MaxPageSize)
{
pageSize = MaxPageSize;
}
@bernos
bernos / MigrationsConfiguration.cs
Created December 12, 2013 07:27
MySql with entity framework 5.x
using MySql.Data.Entity;
namespace MyProject.Migrations
{
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<MySqlEntityFrameworkTest.ChinookContext>
@bernos
bernos / build.proj
Last active August 29, 2015 13:56
MSBuild Templify AfterBuild target example
<!-- Once built, templates belong in %HOMEDIR%\AppData\Roaming\endjin\Templify\repo -->
<Target Name="AfterBuild">
<Message Text="---------------"/>
<Message Text="TEMPLIFY"/>
<Message Text="---------------"/>
<PropertyGroup>
<TemplifyMode>c</TemplifyMode>
<TemplifyPath>"$(MSBuildProjectDirectory)\..\..\TemplifyMsBuildExample"</TemplifyPath>
<TemplifyPackageName>"Templify MS Build Example"</TemplifyPackageName>
@bernos
bernos / 0_reuse_code.js
Created March 16, 2014 01:31
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bernos
bernos / javascript_resources.md
Created March 16, 2014 01:31 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage