Skip to content

Instantly share code, notes, and snippets.

View adamnew123456's full-sized avatar

Chris Marchetti adamnew123456

  • Chapel Hill, NC
View GitHub Profile
@adamnew123456
adamnew123456 / prepared.vbs
Created September 29, 2016 02:29
Prepared Statements in VBA
' Creates a prepared statement and populates its parameters
'
' Usage:
'
' Dim stmt as QueryDef
' Set stmt = PrepareStatement(CurrentDb, "SELECT * FROM T WHERE A = [aval] AND B = [bval]", _
' "aval", 42, _
' "bval", "Carrot Cake")
'
Public Function PrepareStatement(db As Database, sql As String, ParamArray params()) As QueryDef
@adamnew123456
adamnew123456 / case-gen.py
Created January 17, 2017 21:18
431 - HW1 Positive-Case Generator
from collections import namedtuple
import random
import string
import sys
Node = namedtuple('Node', ['grammar'])
Output = namedtuple('Output', ['text'])
# All of these are easier to compute than to specify literally in the grammar
ALPHABET_NODES = [[Output(letter)] for letter in string.letters]
@adamnew123456
adamnew123456 / evil.java
Last active February 2, 2017 02:22
Sample MiniJava File For Parser
class Bean {}
class Main {
// Visibility Access Type id
public static int x;
public int[] x;
private static boolean x;
private Bean x;
private Bean[] xIs_A_Good_Variable_Name18283_28AXY;
@adamnew123456
adamnew123456 / shader.glsl
Created February 20, 2017 02:05
Ghost Shader
vec4 colorAt(in vec2 coord, in int channel) {
if (channel == 0) return texture2D(iChannel0, coord.xy / iChannelResolution[0].xy);
if (channel == 1) return texture2D(iChannel1, coord.xy / iChannelResolution[1].xy);
if (channel == 2) return texture2D(iChannel2, coord.xy / iChannelResolution[2].xy);
if (channel == 3) return texture2D(iChannel3, coord.xy / iChannelResolution[3].xy);
}
float monochrome(in vec4 color) {
return (color.r + color.g + color.b) / 3.0;
}
@adamnew123456
adamnew123456 / driveby.js
Created February 25, 2017 22:11
Driveby Voting On Reddit
function clickAll(elems) {
for (var i = 0; i < elems.length; i++) {
elems[i].click();
}
}
function driveByUpvote() {
clickAll($('[aria-label="upvote"]'));
}
@adamnew123456
adamnew123456 / leaderkey.py
Last active September 18, 2021 19:01
A launcher based upon Spacemacs-like leaders
#!/usr/bin/python3
#
# Command Line
# ------------
# ``python3 leaderkey.py CONFIG-FIlE``
#
# Configuration format
# --------------------
#
# A leaderkey configuration is a normal Python file, with the following
@adamnew123456
adamnew123456 / xslt.cs
Created March 29, 2017 14:30
XSN XSLT
using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
namespace XSLTEvaluator
{
public class MainClass
{
public static void Main(string[] Args)
@adamnew123456
adamnew123456 / ledger.R
Created September 2, 2017 22:14
Basic analysis of ledger files
#!/usr/bin/Rscript
printf <- function(fmt, ...) cat(sprintf(fmt, ...))
# Reads a Ledger file by doing CSV export on the CLI, and then slurping
# it into R's CSV reader.
#
# start and end can be used to limit which entries are allowed in by time,
# and accounts can be used to limit which accounts are read.
ledger.read <- function(filename,
start=NA,
proc jdbc_command {options} {
set classpath [lindex $options 0]
set commands {/usr/bin/java -classpath}
lappend commands "/home/chris/Source/jdbcnotebook/target/server-1.0-SNAPSHOT-jar-with-dependencies.jar:$classpath"
lappend commands {*}[lrange $options 1 end]
return $commands
}
@adamnew123456
adamnew123456 / feed.el
Created July 2, 2018 12:08
Elisp Scripts
(require 'browse-url)
(require 'helm)
(require 'seq)
(require 'url)
(defun xml-node (node)
"Returns the symbol for the node type (e.g. 'li for <li>...</li>)"
(car node))
(defun xml-attr (node attr)