Skip to content

Instantly share code, notes, and snippets.

View dmgig's full-sized avatar
🏠

Dave M. Giglio dmgig

🏠
View GitHub Profile
@dmgig
dmgig / grep_ip.sh
Last active June 1, 2016 19:03
grep regex for ip addresses
#!/usr/bin/env bash
tail -n 1000 /var/log/my.log | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
@dmgig
dmgig / eol-cat.sh
Last active April 20, 2016 20:25
fix line endings during cat
cat windows-EOL.txt | tr '\r' '\n'
@dmgig
dmgig / timeline_table.php
Created April 20, 2016 18:50
Timeline Table
<?php
require 'common.php';
// base dateframes
$dateframe = new DateFrame('1960-01-01', '1974-04-01');
$dateframes = $dateframe->asMonthIntervals(1);
$dateframes = array_reverse($dateframes);
@dmgig
dmgig / php_encryption_test.php
Created April 20, 2016 18:48
PHP Public Key Encryption
<?php
$publicKey = "file://Users/dgiglio/.ssh/mykey.pem";
$plaintext = "String to encrypt";
openssl_public_encrypt($plaintext, $encrypted, $publicKey);
echo $encrypted; //encrypted string
@dmgig
dmgig / AudioContext.html
Created April 20, 2016 18:46
Messy messing with the browser's AudioContext capabilities...
<script type="application/javascript">
// create web audio api context
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// create Oscillator and gain node
// connect oscillator to gain node to speakers
@dmgig
dmgig / phplint.sh
Last active April 4, 2016 16:03 — forked from mathiasverraes/phplint.sh
Recursive PHP Lint script (git tracked files only)
#!/bin/bash
# php linter of git tracked files
# passing --success argument will print no-error files in the list,
# otherwise, only files with parse errors will be displayed.
IFS=$'\n' #split filenames at newlines only
for file in `git ls-tree -r master --name-only`
do
@dmgig
dmgig / index.php
Created April 3, 2016 19:36
Obscenely Simple PHP File Upload
<?php
define("UPLOAD_DIR", "./");
ini_set("upload_max_filesize", "200M");
ini_set("post_max_size", "200M");
if (!empty($_FILES["myFile"])) {
$myFile = $_FILES["myFile"];
if ($myFile["error"] !== UPLOAD_ERR_OK) {
echo "<p>An error occurred.</p>";
@dmgig
dmgig / curlToGet.html
Created March 30, 2016 18:59
Reverse a cURL call to a URL with GET params
url: <b id="output"></b>
<script type="text/javascript">
var curlToGet = function(curl){
var url, data;
var getParams = function(e, i, arr){
flag = this;
@dmgig
dmgig / dg-config-setter-input.html
Last active March 29, 2016 16:43
Sample Config Settings AngularJS App
<div>
<div ng-switch="controller.field_type">
<!-- bool -->
<div ng-switch-when="bool">
<button class="btn btn-default btn-block"
ng-class="controller.config_value ? 'btn-info' : 'btn-warning'"
ng-model="controller.config_value"
ng-click="updateBool()">
@dmgig
dmgig / factory-customer.js
Last active March 25, 2016 18:31
Sample Angular Factory
/**
* https://medium.com/opinionated-angularjs/angular-model-objects-with-javascript-classes-2e6a067c73bc
*/
.factory('Customer', function ($http, $log, KeyMap) {
var Customer = function(OtherCustomer){
this.id = OtherCustomer.id;
this.keymap = KeyMap;
this.comparisons = [];
this.working = false;