Skip to content

Instantly share code, notes, and snippets.

View jcsjcs's full-sized avatar

James Silberbauer jcsjcs

  • Silberbauer Computing
  • Somerset West, South Africa
View GitHub Profile
@jcsjcs
jcsjcs / load_grid.html
Last active August 5, 2017 08:16
AG Grid valueGetter always returns blank
<html>
<head>
<script src="dist/ag-grid-enterprise.js"></script>
</head>
<body>
<h1>Simple ag-Grid Example</h1>
<div id="myGrid" style="height: 100%;" class="ag-blue" data-gridurl="/list/menu_definitions/grid" data-grid="grid">
<script type="text/javascript">
(function() {
@jcsjcs
jcsjcs / fmail
Last active August 29, 2015 14:22
Format code in syntax-highlighted html for clipboard using xclip and rouge.
#!/usr/bin/env ruby
# Format code with syntax highlighting for pasting in emails.
# To use:
# 1) Highlight the code.
# 2) fmail ruby/sql/java_script etc...
# 3) Middle-click in email to paste html code.
#
# CLI program xclip must be installed. http://sourceforge.net/projects/xclip/
@jcsjcs
jcsjcs / open_task_files.sh
Created March 27, 2015 11:13
Script for opening a task file for today and the most recent task file in vim.
#! /bin/bash
# Inspired by Jamis Buck's blog entry:
# http://weblog.jamisbuck.org/2015/3/17/task-tracking-for-neurochemical-brains.html
# Go to tasks folder and open (or create) today's task file
# and the previous task file in vim.
cd ~/tasks
TODAY="tasks_`date '+%Y_%m_%d'`.txt"
@jcsjcs
jcsjcs / checkboxselectcolumn.js
Created April 7, 2014 19:43
Slick Grid checkbox select column plugin with hidden checkboxes
(function ($) {
// register namespace
$.extend(true, window, {
"Slick": {
"CheckboxSelectColumn": CheckboxSelectColumn
}
});
function CheckboxSelectColumn(options) {
@jcsjcs
jcsjcs / fmail_coderay.rb
Last active January 2, 2016 02:49
Syntax highlight selected code for pasting in emails. Requires xclip.
#!/usr/bin/env ruby
# Format code with syntax highlighting for pasting in emails.
# To use:
# 1) Highlight the code.
# 2) fmail ruby/sql/java_script etc...
# 3) Middle-click in email to paste html code.
require 'coderay'
require 'open3'
@jcsjcs
jcsjcs / example-checkbox-row-select-filtered.html
Created August 5, 2013 10:29
Copy of SlickGrid checkbox example displaying loss of selection on filter. Select a few rows. Press the button to log selection. Filter rows. Press button. Select more rows and press button. Unfilter. press button.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../slick.grid.css" type="text/css"/>
<link rel="stylesheet" href="../css/smoothness/jquery-ui-1.8.16.custom.css" type="text/css"/>
<link rel="stylesheet" href="examples.css" type="text/css"/>
<link rel="stylesheet" href="../controls/slick.columnpicker.css" type="text/css"/>
<style>
.slick-cell-checkboxsel {
@jcsjcs
jcsjcs / clear_old_files.rb
Created July 6, 2012 16:31
Ruby script to delete old files.
#!/usr/bin/env ruby
USAGE=<<EOS
Delete files in specified folders that are older than a given number of days.
Options:
-v - verbose. Will list folders and files.
-d - dry run. Like verbose, but does not delete files.
-h - Show this usage help.
Arguments:
@jcsjcs
jcsjcs / dbstruct.rb
Created November 3, 2010 14:09
Modified version of "Database documentation in 50 lines of Sinatra"
# Modified version of "Database documentation in 50 lines of Sinatra"
# at http://www.alandelevie.com/2010/10/26/database-documentation-in-50-lines-of-sinatra/
# (Works with Postgres and MySQL. Possibly sqlite too.)
#
# Useful for quickly comparing two database structures:
# 1) Run with a connection to db1 and choose the sorted view.
# 2) Copy the table structures into the left-hand side of a diff viewer.
# 3) Run with a connection to db2 and choose the sorted view.
# 4) Copy the table structures into the right-hand side of a diff viewer.
# 5) Compare...
# db/migrate/20091123163221_create_orders.rb
class CreateOrders < ActiveRecord::Migration
def self.up
create_table :orders do |t|
t.string :name
t.timestamps
end
end
@jcsjcs
jcsjcs / grepr
Created September 20, 2009 14:55
grepr - simple grep for rails projects
#!/usr/bin/env ruby
class Grepr
def initialize(options, pattern)
@paths = []
@pattern = pattern
@noregex = options.include?('n')
@pattern = "'#{@pattern}'" if pattern.include?(' ')
options.each_char do |opt|
case opt