Skip to content

Instantly share code, notes, and snippets.

☎️
call me on my #!/bin/sh phone

Matthew Loberg mloberg

☎️
call me on my #!/bin/sh phone
Block or report user

Report or block mloberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mloberg
mloberg / mysql.php
Created Aug 30, 2011
Simple PHP MySQL Class
View mysql.php
<?php
class Mysql{
static private $link = null;
static private $info = array(
'last_query' => null,
'num_rows' => null,
'insert_id' => null
);
@mloberg
mloberg / File.Upload.js
Created Nov 6, 2011
MooTools Ajax File Upload
View File.Upload.js
/*
name: [File.Upload, Request.File]
description: Ajax file upload with MooTools.
license: MIT-style license
author: Matthew Loberg
requires: [Request]
provides: [File.Upload, Request.File]
credits: Based off of MooTools-Form-Upload (https://github.com/arian/mootools-form-upload/) by Arian Stolwijk
@mloberg
mloberg / media.sh
Created Jun 17, 2019
Batch convert media files
View media.sh
#!/usr/bin/env bash
set -e
# convert and optmize jpg files to png & gif
# requires imagemagick (brew install imagemagick)
while read -r file; do
echo ">> resizing/converting $file"
name="${file%.*}"
convert "$file" -resize 1600 -quality 85 -strip "${name}.jpg"
convert "$file" -quality 85 -strip -colors 256 "${name}.png"
@mloberg
mloberg / gist:3750653
Created Sep 19, 2012
Find file in git based on md5 checksum.
View gist:3750653
#!/bin/sh
CHECKSUM=$1
FILE=$2
if [[ -z "$CHECKSUM" ]]; then
echo "Usage: $0 md5 file"
exit 1
elif [[ -z "$FILE" ]]; then
echo "Usage: $0 md5 file"
@mloberg
mloberg / gist:2852153
Created Jun 1, 2012
MySQL Slow Query Log Analyzer
View gist:2852153
#!/usr/bin/php
<?php
/**
* The Analyzer class.
*/
class Analyzer {
private $fp;
@mloberg
mloberg / example.php
Created Mar 10, 2011
A simple Postmark PHP Class
View example.php
<?php
require("postmark.php");
$postmark = new Postmark("your-api-key","from-email","optional-reply-to-address");
if($postmark->to("reciver@example.com")->subject("Email Subject")->plain_message("This is a plain text message.")->send()){
echo "Message sent";
}
View gist:467536d2b6a1eb3c92a13b804faedd78
### Keybase proof
I hereby claim:
* I am mloberg on github.
* I am mloberg (https://keybase.io/mloberg) on keybase.
* I have a public key ASDcFyl0kafbvzkZ9nI-2-9d5Kk5XQMLUTnjNRw5p5s_DAo
To claim this, I am signing this object:
View watermark.html
<img src="watermark.php?watermark=watermark.png&src=test.jpg" />
View batch.py
from itertools import islice, chain
def batch(iterable, size):
iterator = iter(iterable)
for first in iterator:
yield chain([first], islice(iterator, size - 1))
@mloberg
mloberg / upload.rb
Created Dec 16, 2011
qq.FileUploader Ruby
View upload.rb
directory = './tmp/'
# ajax upload
if params[:qqfile].class == String
name = params[:qqfile]
string_io = request.body
data_bytes = string_io.read
path = File.join(directory, name)
File.open(path, "w") do |f|
f.write(data_bytes)
end
You can’t perform that action at this time.