Skip to content

Instantly share code, notes, and snippets.

View jarrodhroberson's full-sized avatar

Jarrod Roberson jarrodhroberson

View GitHub Profile

From Oracle: If Table Exists:

The best and most efficient way is to catch the "table not found" exception: this avoids the overhead of checking if the table exists twice; and doesn't suffer from the problem that if the DROP fails for some other reason (that might be important) the exception is still raised to the caller:

BEGIN
   EXECUTE IMMEDIATE 'DROP TABLE mytable';
EXCEPTION
   WHEN OTHERS THEN
      IF SQLCODE != -942 THEN

RAISE;

@jarrodhroberson
jarrodhroberson / error.go
Created November 8, 2023 04:55
Native error interface definition.
type error interface {
Error() string
}
@jarrodhroberson
jarrodhroberson / CalcMD5Worker.js
Created November 26, 2013 00:09
Reading a File in chunks with the HTML5 FileReader API and calculating MD5 hash codes of the contents with the spark-md5 library in a WebWorker.
importScripts('spark-md5.min.js');
function calcMD5(f) {
var blobSlice = Blob.prototype.slice;
var chunkSize = 2097152;
var chunks = Math.ceil(f.size/chunkSize);
var spark = new SparkMD5.ArrayBuffer();
var currentChunk = 0;
var fr = new FileReader();
function purge() {
var promotions = GmailApp.search("category:promotions")
for (var i = 0; i < promotions.length; i++) {
Gmail.Users.Threads.remove('me', promotions[i].getId())
}
var forums = GmailApp.search("category:forums")
for (var i = 0; i < forums.length; i++) {
Gmail.Users.Threads.remove('me', forums[i].getId())
}
package main
import (
"fmt"
"reflect"
"time"
)
type TimeStamp struct {
T time.Time
@jarrodhroberson
jarrodhroberson / App.vue
Created June 6, 2023 01:59
Reactive Component Vue 3
<script setup>
import { ref } from 'vue'
import CustomInput from './CustomInput.vue'
const messages = ref([])
messages.value.push({channel: { title: "Jarrod Roberson"}})
messages.value.push({channel: { title: "Julian Roberson"}})
messages.value.push({channel: { title: "Sebastian Roberson"}})
messages.value.push({channel: { title: "Valentino Roberson"}})
@jarrodhroberson
jarrodhroberson / typesafebuilder.go
Last active May 25, 2023 15:50
typesafebuilder.gotype safe builder in GoType Safe Builder in Go
/*
* It becomes painfully obvious why this pattern is NOT embraced by the Go community.
* Just to be painfully clear, DO NOT DO THIS!
*/
package main
import (
"fmt"
)
@jarrodhroberson
jarrodhroberson / helloworld.asm
Created May 21, 2023 11:29
Hello World! C= 64
; program start
Start
jsr $FF81 ; CINT (clear screen)
sei ; turn off interrupts
ldy #0
sty $d020 ; reset border color
Loop
lda Message,y ; load message byte
beq EOM ; 0 = end of string
clc
@jarrodhroberson
jarrodhroberson / weblogic-application.xml
Created July 22, 2013 16:55
weblogic-application.xml example
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.3/weblogic-application.xsd">
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
</weblogic-application>
@jarrodhroberson
jarrodhroberson / InsertionOrderSet.java
Created November 1, 2011 17:55
Sorted Set implementation that preserves insertion order like a List does
import java.util.*;
public class InsertionOrderSet<E> implements SortedSet<E>
{
private final SortedSet<IndexedEntry<E>> bs;
public InsertionOrderSet(final E[] e)
{
this(Arrays.asList(e));
}