Skip to content

Instantly share code, notes, and snippets.

@melbourne2991
melbourne2991 / _comment.html.haml
Created January 16, 2014 06:33
Nested comments I built on my first rails project before deciding to use disqus instead.
.comment{:class => "c" + nesting.to_s}
.profile
%img{:src => "/assets/profile_image_sample.jpg"}
.message
.username
- if defined? comment.user.username
- if comment.user.username.blank?
= comment.user.first_name
- else
= comment.user.username
@melbourne2991
melbourne2991 / bootstrap-breakpoint-angular.js
Last active November 13, 2017 21:32
Angular Bootstrap Breakpoint Detect
//Below is an example of a directive that let's other directives know when there has been a change in a breakpoint, as well as a
//windows resize, the event is triggered on the window resize and broadcast to child scopes (for this reason it's best to place
//the directive on body or a similar high level element), the arguments contain the new previousBreakpoint will likely return
//null if there is yet to be a change in breakpoint.
app.directive('viewFrame', [function($scope) {
return {
controller: function($scope, $element) {
var width = function() {
return $element.width();
@melbourne2991
melbourne2991 / navbarbstrpimp.js
Created February 5, 2014 13:45
navbarbstrpimp
pantherDirectives.directive('bootstrapNavBar', function() {
return {
scope: {},
template: '<nav class="navbar navbar-default" role="navigation">'
+ '<div class="container-fluid" data-ng-transclude>'
+ '</div>'
+ '</nav>',
transclude: true,
replace: true
}
$('.full_wrap').mousedown(function(e) {
// get container co ordinates
var tcw= $('.tags_container.stores_only').width(),
tch= $('.tags_container.stores_only').height(),
tct= $('.tags_container.stores_only').offset().top,
tcl= $('.tags_container.stores_only').offset().left;
// calculate selectable zone
var xCoordsMin = tcl,
xCoordsMax = tcl + tcw,
var request = require('request');
var cheerio = require('cheerio');
var fs = require('fs');
var readline = require('readline');
var stream = require('stream');
if(process.argv[2] === '-links') {
var url = 'https://example.com/just-sold?price_min=0';
var count = 1;
{
"name": "Genifique",
"version": "0.0.0",
"authors": [
"Will"
],
"private": true,
"ignore": [
"**/.*",
"node_modules",
var fs = require('fs');
var _ = require('lodash');
var cheerio = require('cheerio');
module.exports = {};
module.exports.build = {};
module.exports.build.template = {};
modulesPath = __dirname + '/../../modules/'
@melbourne2991
melbourne2991 / convertdatetoyyyymmdd
Created July 10, 2014 00:17
Converts date objects to YYYY-MM-DD
// Converts date object to yyyy-mm-dd
var convertDateToString = function(timestamp) {
var yyyy = timestamp.getFullYear();
var mm = timestamp.getMonth();
var dd = timestamp.getDate();
if(mm < 10) mm = '0' + mm.toString();
if(dd < 10) dd = '0' + dd.toString();
yyyy = yyyy.toString();
// takes [x, y] array objects for the points
function bezier(t, p0, p1, p2) {
const ay = Math.pow(1 - t, 2) * p0[1];
const by = 2 * (1 - t) * t * p1[1];
const cy = Math.pow(t, 2) * p2[1];
const ax = Math.pow(1 - t, 2) * p0[0];
const bx = 2 * (1 - t) * t * p1[0];
const cx = Math.pow(t, 2) * p2[0];
# --Helper Functions--
# Finds PIDs using port
pidport() {
if [ -z $1 ];
then echo "pidport requires <port>";
return 1;
fi
lsof -n -i:$1 | grep LISTEN | while read line;