Skip to content

Instantly share code, notes, and snippets.

@aponxi
aponxi / README.md
Last active August 29, 2015 14:05
How to: Check the bash shell script is being run by root or not

How to: Check the bash shell script is being run by root or not

by NIX CRAFT on NOVEMBER 12, 2007 · 22 COMMENTS· LAST UPDATED JANUARY 6, 2008 in CENTOS, DEBIAN LINUX, FREEBSD

http://www.cyberciti.biz/tips/shell-root-user-check-script.html

Sometime it is necessary to find out if a shell script is being run as root user or not.

When user account created a user ID is assigned to each user. BASH shell stores the user ID in $UID variable. Your effective user ID is stored in $EUID variable. You can

@Flafla2
Flafla2 / Perlin_Tiled.cs
Last active May 7, 2025 06:09
A slightly modified implementation of Ken Perlin's improved noise that allows for tiling the noise arbitrarily.
public class Perlin {
public int repeat;
public Perlin(int repeat = -1) {
this.repeat = repeat;
}
public double OctavePerlin(double x, double y, double z, int octaves, double persistence) {
double total = 0;
@aponxi
aponxi / README.md
Last active August 29, 2015 14:04
Reports how many folders are there without git repo

No Git

usage

  • Copy script to bin folder ~/bin
  • Run no-git

Output

@aponxi
aponxi / Spritz-Speed-Reading-V2.markdown
Created June 21, 2014 07:43
A Pen by Logan Howlett.
Handlebars is a semantic web template system, started by Yehuda Katz in 2010.
Handlebars.js is a superset of Mustache, and can render Mustache templates in addition to Handlebars templates.
More: http://handlebarsjs.com/
1. Expressions.
1.1 Basic usage.
@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active May 6, 2025 10:00
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@victorquinn
victorquinn / promise_while_loop.js
Last active March 30, 2023 04:29
Promise "loop" using the Bluebird library
var Promise = require('bluebird');
var promiseWhile = function(condition, action) {
var resolver = Promise.defer();
var loop = function() {
if (!condition()) return resolver.resolve();
return Promise.cast(action())
.then(loop)
.catch(resolver.reject);
@kethinov
kethinov / walksync.js
Created September 22, 2013 09:04
List all files in a directory in Node.js recursively in a synchronous fashion
// List all files in a directory in Node.js recursively in a synchronous fashion
var walkSync = function(dir, filelist) {
var fs = fs || require('fs'),
files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach(function(file) {
if (fs.statSync(dir + file).isDirectory()) {
filelist = walkSync(dir + file + '/', filelist);
}
else {
@aponxi
aponxi / cs-jq-plugin-template.coffee
Last active December 21, 2015 14:59 — forked from rjz/cs-jq-plugin-template.coffee
modified to make it check if method/object exists in the class, if its a method calls it.
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->