Skip to content

Instantly share code, notes, and snippets.

View derak-kilgo's full-sized avatar

Derak Kilgo derak-kilgo

View GitHub Profile
@derak-kilgo
derak-kilgo / makepassword
Created March 26, 2015 20:09
php cli password generator
#!/usr/bin/env php
<?php
#accept command line arg for length.
$options = getopt("l:");
if(empty($options['l'])){
$length = 32;
}else{
$length = (int) $options['l'];
}
#may contain unprintable characters. Base64 encode for ease of use. Double the lenght to make sure we have enough data to clip.
@derak-kilgo
derak-kilgo / example.txt
Created June 1, 2015 16:17
Base64 encode image for inline display and save to clipboard.
#Its a one line command which takes 1 arg, a path to the file, which is bundle4.jpg in this case.
php -r 'echo chr(10) . "data:" . mime_content_type($argv[1]) . "," . base64_encode(file_get_contents($argv[1])) . chr(10);' ./bundle4.jpg | pbcopy -Prefer txt
@derak-kilgo
derak-kilgo / noip-update.sh
Created June 25, 2015 19:20
noip.com cli update script
#!/bin/bash
# Updates ip address in the noip DDNS serivce.
# Assumes curl + gnu tools
# Param descriptions taken from API docs.
# http://www.noip.com/integrate/request
#Config
@derak-kilgo
derak-kilgo / blti-launch.php
Created January 6, 2016 16:43 — forked from matthanger/blti-launch.php
Sample code for Basic LTI Consumer in PHP
<?php
# ------------------------------
# START CONFIGURATION SECTION
#
$launch_url = "http://www.imsglobal.org/developers/BLTI/tool.php";
$key = "12345";
$secret = "secret";
$launch_data = array(
@derak-kilgo
derak-kilgo / example.php
Last active September 20, 2021 20:24
Email on error with monolog
<?php
/*
* Configure Logger instance / error mailer functionality
* Assumes you are autoloading monolog.
*/
$initLogger = function(){
//needed for the mail logger. @see http://symfony.com/doc/current/cookbook/logging/monolog_email.html
$transport = new Swift_SmtpTransport($config['smtp']['host'],$config['smtp']['port'],$config['smtp']['security']);
$swiftMessage = new Swift_Message();
$swiftMessage->addTo('[email protected]');
@derak-kilgo
derak-kilgo / cli-export.php
Created February 5, 2016 18:52
Magento Loop through a collection (stand alone)
<?php
if(php_sapi_name()!=="cli"){
echo "Must be run from the command line.";
};
/**
* Setup a magento instance so we can run this export from the command line.
*/
#!/bin/bash
#see your mojo profile for this key. Will change if your password is every updated.
mojo_access_key="xxxxx"
#A specific agent id number. See mojo url for id number.
mojo_assignee_id="xxxxx"
#URL to check for tickets. You can changes the filters to suite your need.
#This one only finds issues assigned to specific id with a status of new or in progress
@derak-kilgo
derak-kilgo / vine_to_gif.rb
Created August 17, 2016 18:27 — forked from seyhunak/vine_to_gif.rb
Vine.co mp4 to GIF using Ruby
# space150 vine-to-GIF
# given a vine.co uri, downloads the MP4 and creates an image sequence / GIF from it
# requires ruby, ffmpeg, and imagemagick
require 'open-uri'
require 'nokogiri'
id = ARGV[0]
# try to convert from URL to id.
@derak-kilgo
derak-kilgo / mp4-to-gif.php
Created August 17, 2016 18:30
Convert a mp4 clip into a gif with php, imagemagick and ffmpeg. From OSX, these are easy to install with homebrew.
<?php
$video = __DIR__ . '/video.mp4';
$fps = 4;
# Convert an MP4 to a GIF - Requires ffmpeg
`ffmpeg -i "$video" -pix_fmt rgb24 -r $fps "$video.gif"`
# optimize the gif - Requires imagemagick
# via http://superuser.com/questions/436056/how-can-i-get-ffmpeg-to-convert-a-mov-to-a-gif
@derak-kilgo
derak-kilgo / matrixish.sh
Created August 17, 2016 19:30 — forked from ttscoff/matrixish.sh
A Matrix-ish display for Bash terminal
#!/bin/bash
#
# matrix: matrix-ish display for Bash terminal
# Author: Brett Terpstra 2012 <http://brettterpstra.com>
# Contributors: Lauri Ranta and Carl <http://blog.carlsensei.com/>
#
# A morning project. Could have been better, but I'm learning when to stop.
### Customization:
blue="\033[0;34m"