Skip to content

Instantly share code, notes, and snippets.

Noj Vek (Manoj P) nojvek

Block or report user

Report or block nojvek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nojvek
nojvek / ObjUtils.watch
Last active Aug 29, 2015
Simple javascript Object.watch
View ObjUtils.watch
/*
MIT Licence
Copyright © 2015 Noj Vek
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
@nojvek
nojvek / watchAndReload.js
Last active Sep 25, 2015
LiveReload CSS
View watchAndReload.js
// Watch for changes and auto-reload
// CSS changes get auto injected, js changes reload current page
var pollInterval = 2; // check every 2 seconds
var jsMap = {"powerbi.js":null, "powerbicommon.js":null};
var cssMap = {"powerbi.css":null, "powerbicommon.css": null};
function getLastModifiedTime(url, callback) {
$.ajax({
type: "HEAD", // HEAD only gives headers, a lot faster
url: url,
@nojvek
nojvek / spaces2tabs.py
Created Jun 27, 2012
Convert Spaces to Tabs
View spaces2tabs.py
import os
import re
#whatever filter you would like to apply
os.system('find * -type f | egrep -v ".svn" | egrep "\.(js|mustache|css|html|txt|less|sass|as|cfml|mxml)$" > /tmp/sourcefiles.txt')
with open('/tmp/sourcefiles.txt') as f:
files = f.read().strip().split("\n")
for file in files:
View differ.coffee
fs = require 'fs'
XXHash = require 'xxhash'
path = require 'path'
#dive = require 'dive'
HashStream = XXHash.Stream
c = console
startTime = Date.now()
mapFileName = 'pbix.json'
rootDir = '../pbix'
View chromeProfileConverter.coffee
fs = require 'fs'
readline = require 'readline'
path = require 'path'
c = console
###
# Helpers
###
parseCliForPath = ->
@nojvek
nojvek / ufw.sh
Created Apr 17, 2016
Ubuntu Firewall Setup
View ufw.sh
sudo apt-get install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow 9000
sudo ufw allow 9001
sudo ufw allow 9002
sudo ufw status verbose
#sudo ufw enable
View ypeescript
public render()
const todos = @.props.model.todos
let shownTodos = todos.filter (todo) ->
switch @.state.nowShowing
case ACTIVE_TODOS:
-< !todo.completed
case COMPLETED_TODOS:
-< todo.completed
default:
@nojvek
nojvek / PNGAlphaTrim.py
Created Jul 19, 2012
Trim transparency of all PNG files in a folder
View PNGAlphaTrim.py
import Image
import sys
import glob
# Trim all png images with alpha in a folder
# Usage "python PNGAlphaTrim.py ../someFolder"
try:
folderName = sys.argv[1]
except :
@nojvek
nojvek / droneseed.ts
Last active Dec 13, 2016
DroneSeed challenge
View droneseed.ts
const MIN_HEIGHT = 4
const MAX_HEIGHT = 8
const HEIGHT_DELTA = MAX_HEIGHT - MIN_HEIGHT
interface Path {
startIndex: number
startHeight: number
endIndex: number
endHeight: number
}
View Object.map.js
/**
* Suppose there was an Object.map function similar to Array.map
* There is some discussion about this on es-discuss but no one has filed a formal proposal yet (someone should!)
* @param {Object} object
* @param {function} callback
*/
Object.map = function(object, callback) {
if (!object) {
throw new TypeError(`object is null or not defined`);
}
You can’t perform that action at this time.