Skip to content

Instantly share code, notes, and snippets.

View jcheng5's full-sized avatar

Joe Cheng jcheng5

View GitHub Profile
<?php
class DbConn
{
private $db; // handle to connection
function __construct()
{
global $db_host, $db_user, $db_pass, $db_name;
package com.joecheng.asyncshim.client;
import com.google.gwt.user.client.Command;
import com.google.inject.Inject;
import com.google.inject.Provider;
/**
* AsyncShim makes it easy to sequester a class behind GWT.runAsync()
* and cause it to be lazy-loaded, while still making it convenient to
* call (some types of) methods on it from other parts of the code that
@jcheng5
jcheng5 / full-width.rb
Created March 23, 2011 19:45
Generate wide character detection code
#!/usr/bin/ruby
require 'pp'
# http://unicode.org/Public/UNIDATA/EastAsianWidth.txt
data = File.read('EastAsianWidth.txt')
data.gsub!(/\s*#.*/, '')
data = data.split
data.reject! {|x| x !~ /;/}
data = data.select {|x| x =~ /;[FW]/}
@jcheng5
jcheng5 / unirange.rb
Created July 28, 2011 00:00
Generate ranges for Unicode character classes
#!/usr/bin/ruby
require 'pp'
Invalid = 0
NonAlpha = -1
Alpha = 1
NumericClasses = ['Nd']
AlphaClasses = ['Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl']
@jcheng5
jcheng5 / todo.txt
Created August 23, 2011 05:15
Living Hope todo list
== Sidebar
- Mailchimp sign up form [Joe]
== What's New
- Provide pictures and captions for slideshow [Natasha, Marc]
- Provide content for homepage posts [Natasha, Marc]
X Provide content for sidebar [Natasha]
- Sign up for newsletter
- Donate
- Click here for overview of Living Hope
@jcheng5
jcheng5 / Shell log.sh
Created June 5, 2012 07:02 — forked from acdha/Shell log.sh
Contortions needed to create an AWS RDS database using UTF-8
brew install rds-command-line-tools
rds-create-db-parameter-group mysql-utf8 -f mysql5.1 -d "MySQL 5.1 configured for UTF-8"
rds-modify-db-parameter-group mysql-utf8 \
--parameters="name=character_set_server, value=utf8, method=immediate" \
--parameters="name=character_set_client, value=utf8, method=immediate" \
--parameters="name=character_set_results,value=utf8,method=immediate" \
--parameters="name=collation_server, value=utf8_general_ci, method=immediate" \
--parameters="name=collation_connection, value=utf8_general_ci, method=immediate"
if (!sameElements(concat(ts1, ts2), new String[] {"Workspace", "History", "Files", "Plots", "Packages", "Help", "VCS", "PkgBuild"}))
{
if (!sameElements(concat(ts1, ts2), new String[] {"Workspace", "History", "Files", "Plots", "Packages", "Help", "VCS"}))
{
if (!sameElements(concat(ts1, ts2), new String[] {"Workspace", "History", "Files", "Plots", "Packages", "Help"}))
return false;
// It's only that the VCS tab is missing. Add it to tabset 1.
ts1.push("VCS");
}
@jcheng5
jcheng5 / server.R
Last active June 17, 2021 18:37
Shiny example: Diamonds Explorer
library(shiny)
library(ggplot2)
function(input, output) {
dataset <- reactive({
diamonds[sample(nrow(diamonds), input$sampleSize),]
})
output$plot <- renderPlot({
@jcheng5
jcheng5 / server.R
Created October 26, 2012 17:27
Simple matrixInput example
library(shiny)
shinyServer(function(input, output) {
output$plot <- reactivePlot(function() {
plot(input$foo)
})
})
@jcheng5
jcheng5 / server.r
Created October 29, 2012 06:21 — forked from wch/server.r
Experiments with shiny and ggplot2
library(shiny)
library(datasets)
library(ggplot2)
tg <- ToothGrowth
tg$dose <- factor(tg$dose)
# Define server logic
shinyServer(function(input, output) {