Skip to content

Instantly share code, notes, and snippets.

Dylan Jhaveri dylanjha

Block or report user

Report or block dylanjha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View view.html
//route
.when('/users/:tab', {
templateUrl: 'views/users/index.html',
controller: 'UsersController'
})
// UsersController
.controller('HomeController', function ($scope, $http, $routeParams) {
$scope.tab = $routeParams.tab
})
@dylanjha
dylanjha / 0. sprockets_depend_on_config.rb
Last active Jan 25, 2018
Adds Sprockets Directive `depend_on_config`. I'm using this to load .yml locale translations on the server into the client in json
View 0. sprockets_depend_on_config.rb
=begin
Useage:
#assets/locales/en.js.erb
```js
//= depend_on_config 'locales/es.yml'
```
=end
@dylanjha
dylanjha / 1. application.html.erb
Last active Jan 31, 2016
Set a `currentUser` in Ember world that all controllers ( and all views ) can access. I'm using Ember 1.5.0 and Ember Data 1.0.0-beta.6
View 1. application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>App</title>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag "templates/all" %>
<%= csrf_meta_tags %>
</head>
<body>
@dylanjha
dylanjha / js-testing.js
Last active Jan 1, 2016
Am I doing this wrong? My goal here is to set up a constructor that I can test. The first bit is how I would normally create this new constructor MyObject... the second bit shows how I have to change it in order to test some of the internal functions. See my first comment below.
View js-testing.js
//this constructor, MyObject is supposed to only have 1 publically exposed method: .getResults()
;(function ( $, window, document, undefined ) {
window.MyObject = function(params){
var error = params.error;
function _shouldFireRequest = function(){
//some logic
return boolean
@dylanjha
dylanjha / sope.js
Created Aug 1, 2013
Javascript Scope. Most languages with C syntax have block scope. All variables defined in a block ( curly braces ) are not visible from outside of the block. Unfortunately, JS does not have block scope, even though its block syntax suggests that it does. JS has function scope. That means that the parameters and variables defined in a function ar…
View sope.js
var foo = function(){
var a = 3
,b = 5;
var bar = function(){
var b = 7
,c = 11;
//Right here: a == 3, b == 7 and c == 11
@dylanjha
dylanjha / apply.js
Created Aug 1, 2013
The Apply Invocation Pattern
View apply.js
myFn = function(msg){
return msg + this.status;
}
o = { status: "killing it" }
myFn.apply(o, ["Your status is: "])
//>> "Your status is: killing it"
View .gitconfig
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
@dylanjha
dylanjha / script.js
Created Jul 16, 2013
a little javascript flash message. see demo at: http://jsfiddle.net/dylanjha/kca9p/
View script.js
<div id='nav'>
<ul class='nav-list'>
<li class='nav-item'><a href="javascript://">Home</a></li>
<li class='nav-item'><a href="javascript://">There</a></li>
</ul>
</div>
<div id='flash-container' class='flash-container'>
</div>
<div id='content'>
Here is some content.
@dylanjha
dylanjha / css3-mixins.css.scss
Last active Dec 19, 2015
A bunch of handy mixins for SASS. Who ever thought vendor prefixes were a good idea, anyway?
View css3-mixins.css.scss
// Border Radius
@mixin round($radius: 4px) {
-moz-border-radius: $radius;
-webkit-border-radius: $radius;
border-radius: $radius;
}
// Box Shadow
@mixin shadow($shadow1: 0 0 4px #0A0A0A, $shadow2:false, $shadow3:false, $shadow4:false, $shadow5:false) {
$params: $shadow1;
@if $shadow2
View array.remove.js
Array.prototype.remove = function(o){
var i = this.indexOf(o)
, v = this[i];
this.splice(i, 1);
return v;
}
You can’t perform that action at this time.