Skip to content

Instantly share code, notes, and snippets.

@jar-o
jar-o / DBIxOut.pm
Last active January 9, 2017 05:03
Want to see the trace leading up to the sql output? Here you go.
=pod
Put this is in the module in which you want to see SQL:
use DBIxOut;
my $dbout = DBIxOut->new();
$dbout->enable_from_rs($resultset);
# OR

Keybase proof

I hereby claim:

  • I am jar-o on github.
  • I am jarobson (https://keybase.io/jarobson) on keybase.
  • I have a public key whose fingerprint is 5967 9910 54FA A42E B82F 480A CCA6 11BB 4974 1C62

To claim this, I am signing this object:

@jar-o
jar-o / ToSql.pm
Created September 26, 2016 23:30
A::Moose::Role::ToSql - convert a moose object into a CREATE TABLE statement, more-or-less
package A::Moose::Role::ToSql;
use Moose::Role;
use JSON;
sub sql_table {
my $self = shift;
my %ok_types = (
Str => 'character varying(255)',
Int => 'integer',
@jar-o
jar-o / maximal-square.py
Last active March 16, 2019 17:48
Maximal square solution in Python
###### For submission to https://leetcode.com/problems/maximal-square/
class Solution(object):
def maximalSquare(self, matrix):
# handle 0 and 1 dimensional arrays
if len(matrix) == 0: return 0
if len(matrix) == 1:
for i in range(len(matrix[0])):
if matrix[0][i] == '1': return 1
@jar-o
jar-o / compress-multipage-tiff.go
Last active April 10, 2018 15:40
Simple go app that uses ImageMagick to compress multipage TIFFs without losing the pages.
/*
# This werks in OSX ... need to build the C deps locally, then run your go app
# with the appropriate CGO* flags.
http://www.imagemagick.org/download/releases/ImageMagick-7.0.6-10.tar.xz
tar xvzf ImageMagick-7.0.6-10.tar.xz
cd ImageMagick-7.0.6-10
mkdir dist
export CGO_IMAGEMAGICK_PREFIX=`pwd`/dist
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8" />
<title>ReDoc documentation</title>
<!-- needed for adaptive design -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {

Keybase proof

I hereby claim:

  • I am jar-o on github.
  • I am jrobson (https://keybase.io/jrobson) on keybase.
  • I have a public key ASCKhgdIGGhBtrQPu4hdVvIjmqQSGNm_xKbJRAxprxT7Rgo

To claim this, I am signing this object:

@jar-o
jar-o / sign.js
Created October 29, 2021 15:32
Web3 examples for ecrecover
const Web3 = require('web3')
var utils = require('ethereumjs-util');
const provider = new Web3.providers.HttpProvider('http://localhost:8545')
const web3 = new Web3(provider)
const dorecover = async function(){
// Recover using account from ganache-cli
var accounts = await web3.eth.getAccounts()
let msg = 'I shill your promotion'
@jar-o
jar-o / Converter.sol
Created February 24, 2022 14:55
Solidity - convert uint256 array to bytes
contract Converter {
function u256a_tobytes(uint256[] memory arr) public pure returns (bytes memory) {
bytes memory b = new bytes(arr.length*32);
for (uint256 i = 0; i < arr.length; i++) {
uint256 x = arr[i];
uint256 j = 32+(i*32);
assembly {
mstore(add(b, j), x)
}
}
#!/usr/bin/env bash
{ # Prevent execution if this script was only partially downloaded
set -e
tmpfile=$(mktemp)
trap 'rm $tmpfile' EXIT
cat > "$tmpfile" <<'EOF'
GREEN='\033[0;32m'