Skip to content

Instantly share code, notes, and snippets.

View jeffcogswell's full-sized avatar

Jeffrey Cogswell jeffcogswell

View GitHub Profile
@jeffcogswell
jeffcogswell / q_example.js
Last active August 12, 2022 01:22
Here's another chaining example on using q.js. This doesn't have any error handling, as I just want to demonstrate the chaining concept. Please read the comments carefully, as I start out with a non-q example, to show the order of flow. Please post comments if there's anything that isn't clear and I'll try to revise it as needed.
// Q sample by Jeff Cogswell
/*===========
We want to call these three functions in sequence, one after the other:
First we want to call one, which initiates an ajax call. Once that
ajax call is complete, we want to call two. Once two's ajax call is
complete, we want to call three.
BUT, we don't want to just call our three functions in sequence, as this quick
@jeffcogswell
jeffcogswell / create_C_index.js
Last active August 29, 2015 14:03
Cloudant Index Creation using node and nano.js
/*
nano doesn't yet have support for Cloudant's new index feature,
but you can still do it using nano's request function.
This code creates an index.
To try this, first replicate the database as per
instructions here:
http://docs.cloudant.com/guides/cloudant-query.html
/*
nano doesn't yet have support for Cloudant's new index feature,
but you can still do it using nano's request function.
This code queries an index.
To try this, first replicate the database as per
instructions here and make sure you created an index.
(Also check out my node.js code to create the index
here:https://gist.github.com/jeffcogswell/1c2f06f5dcd152c055b6)
@jeffcogswell
jeffcogswell / simplefileline.js
Created December 7, 2015 22:08
Demo of simple way to get file/line in node.js
var path = require('path');
function getfileline(stacklevel) {
var index = stacklevel || 2;
var stacklist = (new Error().stack).split('\n')[index];
// regexps borrowed from "tracer" in npm
var stackReg = /at\s+(.*)\s+\((.*):(\d*):(\d*)\)/gi;
var stackReg2 = /at\s+()(.*):(\d*):(\d*)/gi;
var sp = stackReg.exec(stacklist) || stackReg2.exec(stacklist);
var result = {
func: sp[1],
@jeffcogswell
jeffcogswell / sliderdemo.html
Last active December 14, 2015 02:13
Basic slider demo
<!-- Try taking out the overflow:hidden to see more visually how the whole things works -->
<style>
.onramp {
width:500px;
height:500px;
overflow: hidden;
border: 5px solid black;
}
@jeffcogswell
jeffcogswell / resize.md
Created February 19, 2016 13:36
Resize linux windows via command line

(You may need to install wmctrl via package manager)

List the windows:

wmctrl -l

Resize to, for example, 1280x720 and move to upper-left corner:

wmctrl -r '(first few chars of name)' -e 1,0,0,1280,720

{
"color_scheme": "Packages/Colorsublime - Themes/GitHubCleanWhite.tmTheme",
"font_face": "Droid Sans Mono",
"font_size": 9,
"ignored_packages":
[
"Vintage"
],
"line_padding_bottom": -1,
"line_padding_top": -1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>Jeff1</string>
[Desktop Entry]
# This file goes in /usr/share/xsessions
# -rw-r--r-- 1 root root 1507 Feb 27 09:07 LXDE.desktop
# The names/descriptions should really be better
Name=LXDE
Comment=LXDE - Lightweight X11 desktop environment
Comment[ar]=لكسدي - بيئة سطح مكتب X11 خفيفة
Comment[cs]=LXDE - lehké X11 pracovní prostředí
Comment[de]=LXDE - Leichtgewichtige X11 Desktop-Umgebung
Comment[es]=LXDE - Entorno de Escritorio X11 Liviano
@jeffcogswell
jeffcogswell / Update_Java_Alternatives.md
Last active August 2, 2020 16:33
Update Alternatives for Java