Skip to content

Instantly share code, notes, and snippets.

View npras's full-sized avatar
😃
Coding all the time

Prasanna Natarajan npras

😃
Coding all the time
View GitHub Profile
@npras
npras / application.js
Created January 5, 2025 00:50
Javascript in Rubular.com
function $w(e) {
return (e = e.strip()) ? e.split(/\s+/) : []
}
function $H(e) {
return e && e.constructor == Hash ? e : new Hash(e)
}
function $(e) {
if (1 < arguments.length) {
@npras
npras / build.sh
Created December 27, 2024 14:47
Bash Script to Build a Static Website From a Bunch of Markdown Files
#!/usr/bin/env bash
# set -euxo pipefail
set -euo pipefail
die() {
printf "%s\n" "$*" > "$(tty)"
exit 1
}
@npras
npras / acme-client.conf
Created November 6, 2024 05:29 — forked from morgant/acme-client.conf
OpenBSD httpd & relayd reverse proxy configuration
authority letsencrypt {
api url "https://acme-v02.api.letsencrypt.org/directory"
account key "/etc/acme/letsencrypt-privkey.pem"
}
# example.net
domain example.net {
alternative names { www.example.net }
domain key "/etc/ssl/private/example.net.key"
domain certificate "/etc/ssl/example.net.crt"
@npras
npras / af2_original_submission.rb
Last active March 10, 2017 14:10
AF - Codility: Task2
def solution(a)
total = a.size
lindex = a.size-1
sorted = a.sort
min = total
combos = []
return 0 if a == sorted
(2..total).each do |pair_size|
@npras
npras / bindMethod.js
Last active February 22, 2017 12:54
Gist explaining method binding to outer scope
let myLib = (function(){
this.libName = 'in lib';
let obj = {
libName: 'in obj',
toCaps() {
return this.libName.toUpperCase();
}
};
@npras
npras / watcher.js
Created February 20, 2017 13:35
VueJS - Implementing Computed Property - Part Two
class Watcher {
constructor(vm, valueFn) {
this.vm = vm;
this.getter = valueFn;
this.value = this.get();
}
get() {
let value;
@npras
npras / vuejs-source.js
Created February 20, 2017 12:54
VueJS - Implementing Computed Property - Part One
const Watcher = require('./watcher');
const noop = function () {};
const sharedPropDef = {
enumerable: true,
configurable: true,
get: noop,
set: noop
};
@npras
npras / vue_experiment1.js
Created January 13, 2017 13:36
Reproduce Vue's data object proxy behaviour
// https://vuejs.org/v2/guide/instance.html
//
//
//function Vue(opts){
//for(var key in opts.data){
//this[key] = opts.data[key]
//}
//}
function Vue(opts){
this._data = opts.data;
class XMLBuilder
def initialize
@d = {}
end
def to_xml
@d
end
@npras
npras / js_fn_def_and_calling.js
Created March 17, 2016 07:47
javascript function definition and calling syntax
// this is function definition.
// you can make a function take zero or more arguments (also called as parameters)
// This Dog fn takes one argument: 'name'
function Dog(name){
return "hello, my name is: " + name;
}
// calling the Dog function
Dog('tommy'); // this will return "hello, my name is: tommy"