Skip to content

Instantly share code, notes, and snippets.

View streaming_csv.patch
Index: src/main/java/org/example/questionn/csv/CsvRenderer.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/org/example/questionn/csv/CsvRenderer.java (revision 13e0a8fb07a40e89c39ea8f8176f4c2e6b590774)
+++ src/main/java/org/example/questionn/csv/CsvRenderer.java (date 1592660439551)
@@ -3,11 +3,13 @@
import ratpack.handling.Context;
import ratpack.render.RendererSupport;
View derEncodeECDSASignatureToUinit8Array.js
function derEncodeECDSASignatureToUinit8Array(signatureUint8Array) {
let out_sigder = new ArrayBuffer(72);
let out_sigder_DV = new DataView(out_sigder);
let out_sigder_BA = new Uint8Array(out_sigder);
// Need to caress into dumb der format ..
let i;
let lead_s = 0; // leading zeros
let lead_r = 0;
View TinyFPGA_BX_SPIDriver_flash.py
#!/usr/bin/env python3
## Highly advise running `setserial /dev/ttyUSB0 low_latency` before flashing
from spidriver import SPIDriver
import struct
import time
import sys
import getopt
View gb-link.js
@Palmr
Palmr / ImageUtil.java
Created May 28, 2015
Massive text draw function
View ImageUtil.java
//Draw a wrapped sting
private static boolean isBreakable(char c) {
return (c == ' ' || c == '\t' || c == '-' || c == '\\' || c == '/' || c == '_');
}
private static boolean isNewLine(char c) {
return (c == '\n' || c == '\r');
}
/**
* Draw a string onto a graphics2d object, wrapping words at pWidth pixels wide.
@Palmr
Palmr / tag-sorter.js
Created Oct 10, 2014
Sort tags by suggestion text value
View tag-sorter.js
// This is whatever has your JSON before you call the tagger
var tagItemsJSON = ...
// This takes the JSON and splits it into an array of the items in it
// It then sorts that array by the suggestion field on each item
var sortedBySuggestion = $.map(tagItemsJSON, function(p){return p;}).sort(function(a, b){
if(a.suggestion < b.suggestion ) return -1;
if(a.suggestion > b.suggestion ) return 1;
return 0;
});
View trello-solve.js
// for some reason the challenege only let you use these letters, not full A-Z
var letters = "acdegilmnoprstuw";
// Implementation of their hash function to test against
function doHash(string) {
var hash = 7;
for(var i = 0; i < string.length; i++) {
hash = (hash * 37 + letters.indexOf(string[i]));
}
return hash;
View Database.php
<?php
class Database {
private $dbHandle;
private $preparedStatements = array();
public $rowCount;
public $lastInsertId;
public function __construct($host, $database, $username, $password, $errorMode='silent') {
try {
@Palmr
Palmr / gist:7643101
Created Nov 25, 2013
VBA to deal with some stock control stuff
View gist:7643101
Attribute VB_Name = "Module1"
Sub Stockreport1()
Attribute Stockreport1.VB_ProcData.VB_Invoke_Func = " \n14"
' Comments start with apostrophes :)
' Select a bunch of columns, then remove them
Range("F:F,I:I,X:X,AD:AD,AE:AE,AA:AC,AH:AP").Select
Selection.Delete Shift:=xlToLeft
' Insert a new column and put "Stores OOS" in the first item to be the title
@Palmr
Palmr / gist:4526839
Last active Dec 11, 2015
Subtract A, r instruction for the z80 in a gameboy
View gist:4526839
void Instructions::do8bitSubRegToA(CPU* cpu, BYTE (Registers::*getRegFunc)()){
BYTE lInitialValue = cpu->reg->getA();
BYTE lToSub = (cpu->reg->*getRegFunc)();
WORD lTotal = lInitialValue - lToSub;
// If the lower nibble of the original value is less than the lower nibble of what we're subtracting, it'll need a half carry
cpu->reg->setFlagH((lInitialValue & 0x0f) < (lToSub & 0x0f)? 1 : 0);
// If the original value is less than we're subtracting it'll carry
cpu->reg->setFlagC(lInitialValue < lToSub ? 1 : 0);
You can’t perform that action at this time.