Skip to content

Instantly share code, notes, and snippets.

Error:
Problem at line 20 character 21: 'options' is already defined.
var options = $.extend(defaults, options);
Problem at line 39 character 47: Use '===' to compare with 'true'.
if (defaults.less == true) {
/*
* truncatable 1.2 - jQuery lightwieght text truncation plugin
*
* Copyright (c) 2009 Philip Beel (http://www.theodin.co.uk/)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Revision: $Id: jquery.truncatable.js 2009-08-20 $
*
*/
@i8ramin
i8ramin / authentications_controller.rb
Created October 16, 2010 22:24
AuthenticationsController
class AuthenticationsController < ApplicationController
def index
@authentications = current_user.authentications if current_user
end
def create
omniauth = request.env["omniauth.auth"]
authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
if authentication
@i8ramin
i8ramin / gbgrep.rb
Created March 30, 2012 21:31 — forked from nas/gbgrep
git blame with grep
#!/usr/local/bin/ruby
grep = `git grep -n #{ARGV[0]} #{ARGV[1]}`
puts "\n-----------------------------------------------------------"
puts "GREP RESULT"
puts '-----------------------------------------------------------'
puts grep
files = grep.scan /.*\:\d+/
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
# Screenshot: http://i.imgur.com/s0Blh.png
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
@i8ramin
i8ramin / controllers.js
Last active December 17, 2015 23:39
Trying to get twitter's typeahead.js to play nicely with angular js templates ... and failing.
module.controller('SearchCtrl', ['$scope', '$compile', '$templateCache', function ($scope, $compile, $templateCache) {
// I figured out how to read my angular template from the $templateCache, but not
// sure how to make it "come to life" with the scope and whatnot.
var memberCardTpl = $templateCache.get('member-card.html');
// I can use Hogan to compile the angular template, but none of the directives work. Hogan
// knows nothing about Angular.
//var resultTpl = Hogan.compile($templateCache.get('member-card.html'));
// this scoped variable is set in the controller and then later
@i8ramin
i8ramin / multifilter.js
Created June 20, 2013 18:37
Angular JS filter that behaves much like the built in filter one, but allows you to filter with multiple values, space separated. For example "big orange round"
(function () {
'use strict';
angular.module('ConferenceRoomApp').filter('multifilter', function ($filter) {
return function (collection, query) {
var filteredCollection = collection;
var queryTokens = query ? query.split(' ') : [query];
// user entered more than word
if (queryTokens.length > 1) {
@i8ramin
i8ramin / ordinalize.js
Created June 20, 2013 18:40
Add this to digits and get the ordinal representation like 1st, 2nd 3rd, 113th, etc. (logic borrowed from Rails ordinalize helper)
(function () {
'use strict';
angular.module('ConferenceRoomApp').filter('ordinalize', function () {
return function (number) {
var res = number.toString();
if (/(11|12|13)/.test(Math.abs(number) % 100)) {
res = number + 'th';
} else {
(function() {
'use strict';
angular.module('App').directive('tagsManager', function TagsManager() {
return {
restrict: 'A',
scope: false,
link: function (scope, element, attr) {
var hiddenInput = ???;
{
"name": "mySteroidsProject",
"version": "0.1.0",
"description": "My awesome AppGyver Steroids project.",
"repository": "N/A",
"readme": "N/A",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",