Skip to content

Instantly share code, notes, and snippets.

sudo pg_dropcluster 10 main --stop
sudo pg_upgradecluster 9.6 main
sudo pg_dropcluster 9.6 main
sudo apt purge postgresql-9.6 postgresql-client-9.6 postgresql-contrib-9.6
@nileshk
nileshk / CandidateData.tsx
Created August 14, 2018 11:46
DPCF Endorsed Candidates
export interface CandidateInfo {
name: string;
county: string;
position: string;
district?: string;
url?: string;
}
export const StateWideCandidates: CandidateInfo[] = [
{name: "Andrew Gillum", county: "", position: "Governer", district: "Florida", url: "https://andrewgillum.com/"},
@nileshk
nileshk / app.conf
Created February 2, 2018 02:48
supervisord config for Django + pyenv + pyenv-virtualenv + gunicorn
[program:_appname_]
command = /home/_username_/.pyenv/versions/venvname/bin/gunicorn -w 1 -b 127.0.0.1:8000 --pythonpath=. --reload wsgi:application
directory=/home/_username_/sites/_appname_/
environment=PATH="/home/_username_/.pyenv/versions/venvname/bin:/home/_username_/.pyenv/shims:/home/_username_/.pyenv/bin:",DJANGO_SETTINGS_MODULE="_appname_.settings",HOME="/home/_username_"
user=_username_
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
stderr_logfile=/home/_username_/log/_appname_-stderr.log
@nileshk
nileshk / keybase.md
Created January 13, 2018 01:25
keybase.md

Keybase proof

I hereby claim:

  • I am nileshk on github.
  • I am nileshk (https://keybase.io/nileshk) on keybase.
  • I have a public key ASAACiFW0FufTmiLvUrY2P8EOMlNvitNsLrQ_ZkirOxW4wo

To claim this, I am signing this object:

@nileshk
nileshk / emacs.reg
Created March 9, 2017 20:36
Emacs Registry Entry to configure Windows context menu
REGEDIT4
[HKEY_CLASSES_ROOT\*\shell]
[HKEY_CLASSES_ROOT\*\shell\openwemacs]
@="&Emacs"
# The above value appears in the global context menu,
# i.e., when you right click on a file.
# (The '&' makes the next character a shortcut.)
"Icon"="C:\\Programs\\emacs\\bin\\emacs.exe,0"
# The above uses the icon of the Emacs exe for the context
@nileshk
nileshk / osx_sqlplus_oracle_instant_client.sh
Created December 16, 2015 20:14
Example of dynamically setting DYLD_LIBRARY_PATH to Oracle Instant Client folder for running sqlplus on Mac OS X
#!/bin/bash
if [[ "$OSTYPE" == "darwin"* ]]; then
export DYLD_LIBRARY_PATH=$(dirname $(which sqlplus))
fi
# ... rest of your script that calls Oracle sqlplus
@nileshk
nileshk / BeanCompareUtil.java
Created September 9, 2014 01:52
Java 8 bean comparison static method using lambdas of getters to specify which properties to compare
package com.nileshk;
import java.util.function.Function;
import java.util.stream.Stream;
public class BeanCompareUtil {
public static <T> boolean compareBeans(T bean1, T bean2, Function<T, Object>... getters) {
return Stream.of(getters).allMatch(getter -> {
Object val1 = getter.apply(bean1);
@nileshk
nileshk / base_url.js
Created August 18, 2014 18:35
Get current "base" URL (without the document portion or parameters)
// Get current URL without the document portion or parameters
// For example, if the URL is:
// http://hostname:8080/path/to/application/document.html?param1=1&param2=2
// baseUrl will be:
// http://hostname:8080/path/to/application/
var baseUrl = [location.protocol, '//', location.host, location.pathname.split('/').slice(0, -1).join('/'), '/'].join('');
@nileshk
nileshk / datasource_info.jsp
Created October 7, 2013 18:27
JSP page to retrieve DataSource (Apache DBCP in this example) from Spring context and display status information for the database connection pool. Meant as a general example for how to access the Spring context from JSP pages (e.g. could be useful in debugging a running application in production where you could drop in JSP pages to evaluate thin…
<!DOCTYPE html>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.apache.commons.dbcp.BasicDataSource" %>
<%
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application);
BasicDataSource dataSource = (BasicDataSource) context.getBean("dataSource");
%>
<html>
<head>
@nileshk
nileshk / jar-list-packages.py
Created September 28, 2013 04:44
Python script to list the packages contained in a folder full of jar files (e.g. for scanning jar files in WEB-INF/lib)
#!/usr/bin/python
from __future__ import print_function
import string
import os
import sys
import re
import argparse
from subprocess import Popen, PIPE