Skip to content

Instantly share code, notes, and snippets.

View squallstar's full-sized avatar
🍉

Nicholas Valbusa squallstar

🍉
View GitHub Profile
@squallstar
squallstar / example.js
Last active November 27, 2015 15:54
bb collection
var Beacon = Backbone.Model.extend({
defaults: {
name: String
}
});
var Beacons = Backbone.Collection.extends({
model: Beacon,
url: '/beacons'
});
@squallstar
squallstar / searching.sh
Last active August 29, 2015 14:17
Unix Cheatsheet
# Search for a string in files
grep -r "findme" .
# List processes filtered by a string
ps -aux | grep httpd
@squallstar
squallstar / tree.js
Last active August 29, 2015 14:14
Generate tree from flat pages
var pages = [
{id: 1, parent: null, name: 'First'},
{id: 2, parent: null, name: 'Second'},
{id: 3, parent: 2, name: 'First child of second'},
{id: 4, parent: 2, name: 'Second child of second'},
{id: 5, parent: 2},
{id: 6, parent: 4},
{id: 7, parent: 4},
{id: 8, parent: 6}
];
@squallstar
squallstar / aggregate.json
Created September 15, 2014 11:34
Suggested tags (Mongo aggregate)
[
{
"$match": {
"tags": {
"$in": [
"android",
"apple"
]
}
}
@squallstar
squallstar / git commands.sh
Last active August 29, 2015 14:05
Some useful git commands
# Fetch all the branches and their commits from the repo
git fetch origin
# Just fetch the branches from the repo
git fetch -p
# Display the remote branches
git branch -r
# Setting a local branch remote to the one on the origin
@squallstar
squallstar / mongo.php
Last active August 29, 2015 14:05
Mongo PHP Helper
<?php
$GLOBALS['__DB'] = false;
function collection($name = FALSE)
{
if (!$GLOBALS['__DB'])
{
$connection = new MongoClient("http://localhost:27017");
$dbname = "database_name";
@squallstar
squallstar / layer.coffee
Created July 9, 2014 15:52
data wrapper
Layer =
getCollections: (callback) ->
collections = db.extractCollections()
return callback(collections) if collections.length
API.getCollections
success: (data) ->
collections = db.saveAndGetCollections data
@squallstar
squallstar / HipChatter.API.cs
Last active August 29, 2015 14:03
hipchatter bits
namespace HipChatter.Libs
{
public sealed class API
{
private static readonly API instance = new API();
public ObservableCollection<Contact> Contacts = new ObservableCollection<Contact>();
public ObservableCollection<Room> Rooms = new ObservableCollection<Room>();
public ObservableCollection<Chat> Chats = new ObservableCollection<Chat>();
@squallstar
squallstar / onscroll.js
Created March 13, 2014 11:24
Best cross-device way to implement Javascript onScroll event on a browser
window.onscroll = function() {
var top = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
console.log(top);
}
@squallstar
squallstar / cache.php
Last active June 11, 2018 16:37
PHP Cache like Rails.cache.fetch
<?php
/**
* PHP Cache class inspired by Rails.cache.fetch
*
* @author Nicholas Valbusa - @squallstar
* @copyright Copyright (c) 2014, Nicholas Valbusa
* @license GNU/GPL (General Public License)
* @link https://gist.github.com/squallstar/9093354
*
*/