Skip to content

Instantly share code, notes, and snippets.

View andreisebastianc's full-sized avatar

Andrei Sebastian Cîmpean andreisebastianc

View GitHub Profile
@andreisebastianc
andreisebastianc / .bashrc
Created January 15, 2014 05:15
Git branch in terminal
# Git branch in prompt.
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\e[1;34m\]'
c_path='\[\e[0;32m\]'
c_git_clean='\[\e[0;36m\]'
c_git_dirty='\[\e[0;35m\]'
else
c_reset=
c_user=
/*
* From css-tricks.com
* http://css-tricks.com/snippets/css/media-queries-for-standard-devices/
*/
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
@andreisebastianc
andreisebastianc / ex.html
Created November 20, 2013 19:31
Dropdown central handler example
<div class="trips dropdown auto-complete destination">
<div class="element">
<div class="top passive">
<span class="hint">
eg. City Name, Hotel Name, Region Name, etc.
</span>
</div>
<ul class="options overlap">
<li class="top">
<input class="input default" type="text" name="destination" id="destination-input" value="" />

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@andreisebastianc
andreisebastianc / cometdconn.js
Created March 19, 2013 19:43
An approach on getting real time communication for backbone models without spamming channels for cometd. Can be easily updated to work for socket.io . Requires PubSub. The same approach can be used for sending information through channels.
//..
socket.subscribe('channel',function (data){
var data = JSON.parse(data.data);
// or you could search in a collection for the package you are looking for and handle the result
PubSub.publish('topic'+data.id, data);
});
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
@andreisebastianc
andreisebastianc / promises.md
Created October 29, 2012 06:01 — forked from domenic/promises.md
You're Missing the Point of Promises

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
    // the rest of your code goes here.
});
@andreisebastianc
andreisebastianc / Gemfile
Created September 14, 2012 06:25
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@andreisebastianc
andreisebastianc / fiddle.css
Created August 14, 2012 12:18
Google Maps JavaScript API v3 - Multiple Animated Map
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#harita_canvas { height: 100% }
@andreisebastianc
andreisebastianc / example-user.js
Created May 4, 2012 13:11 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9-_]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);