Skip to content

Instantly share code, notes, and snippets.

View jkristoffer's full-sized avatar
👀
What's happening?

Juan Kristoffer jkristoffer

👀
What's happening?
View GitHub Profile
@jkristoffer
jkristoffer / .bash_aliases
Last active September 23, 2016 03:09
Server Stuff
alias dockercleanv='/root/DockerHelpers/docker-cleanup-volumes/docker-cleanup-volumes.sh'
alias dockernsenter='/root/DockerHelpers/nsenter-quick/nsenter-quick.sh'
@jkristoffer
jkristoffer / watcher.c
Created May 12, 2015 06:42
Unix Inotify in C
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <linux/inotify.h>
#define EVENT_SIZE ( sizeof (struct inotify_event) )
#define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
int main( )
@jkristoffer
jkristoffer / gist:a41fac0337163d003072
Created February 17, 2016 01:27
jQuery Smooth Scroll Snippet
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
@jkristoffer
jkristoffer / tmux.cheat
Created May 20, 2016 03:54 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@jkristoffer
jkristoffer / saveToFile.js
Last active September 23, 2016 03:55
Chrome Snippets
(() => {
'use strict';
if(!window.hasOwnProperty('jkriss')){
window.jkriss = {};
}
window.jkriss.saveToFile = function(obj){
var text = typeof obj === 'string' ? obj : JSON.stringify(obj);
var blob = new Blob([text], {type:'application/json'});
@jkristoffer
jkristoffer / angular-dialog.service.ts
Last active August 10, 2017 08:02
Angular 1.5.x Bootstap-like Dialog Service in Typescript
/// <reference path="./index.d.ts" />
import * as ng from 'angular';
let style = require('./dialog.scss');
const DialogComponentModule = ng.module('Components.dialog', []);
let dialogService: ng.Injectable<Function> = function (
$document: ng.IDocumentService,
$compile: ng.ICompileService,
@jkristoffer
jkristoffer / create-user.sh
Last active October 4, 2017 04:10
Linux Create User Script
#!/bin/bash
# Script to add a user to Linux system
# -------------------------------------------------------------------------
# Copyright (c) 2007 nixCraft project <http://bash.cyberciti.biz/>
# This script is licensed under GNU GPL version 2.0 or above
# Comment/suggestion: <vivek at nixCraft DOT com>
# -------------------------------------------------------------------------
# See url for more info:
# http://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html
# -------------------------------------------------------------------------