Skip to content

Instantly share code, notes, and snippets.

@th3d0g
th3d0g / gist:0ebb9c6daadeb61570dba8896b37adab
Last active January 19, 2017 21:57
Install RPi.GPIO on another distro
sudo apt-get install build-essential
sudo apt-get install python-dev
// Maybe need to install PIP
sudo pip install RPi.GPIO
@th3d0g
th3d0g / getvars.js
Last active September 26, 2016 20:11
Grab GET URL variables from Javascript
// Grab GET URL variables from JS.
// credit: https://css-tricks.com/snippets/javascript/get-url-variables/
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
@th3d0g
th3d0g / secondsToTime.js
Created September 26, 2016 19:23
Convert seconds to hh:mm:ss
// Format seconds to hh:mm:ss.
function formatSeconds(seconds)
{
var date = new Date(1970,0,1);
date.setSeconds(seconds);
return date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
}
@th3d0g
th3d0g / PListiOS.cs
Last active September 22, 2024 13:02
Unity PostProcessBuid script for editing the PList file within the Xcode project. This example will enable push notifcations.
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.Collections;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
using System.IO;
// PListiOS - Edit the PList file.
@th3d0g
th3d0g / mailchimp_listsubscribe.php
Created July 17, 2016 20:08 — forked from anonymous/mailchimp_listsubscribe.php
Mailchimp Subcribe to List PHP
<?php
// Populate using POST vars
$data = [
'email' => '[email protected]',
'status' => 'subscribed'
];
var_dump( syncMailchimp($data) );
/////////////////////
// Use ADB over WIFI.
/////////////////////
// Run ADB commands (e.g. logcat) with your device connect via WIFI rather than USB.
// Note; Can be slow to push/install larger APK files.
// 1. Set port.
adb tcpip 5555
@th3d0g
th3d0g / gist:eb958a5d1ed5695536ff
Created March 2, 2016 16:24
DOT Env Loader PHP
// Load either live or dev .env
(new Dotenv\Dotenv(__DIR__.'/../', ( strpos( gethostname(), 'liveserver.com' ) !== false ) ? '.env.live' : '.env' ) )->load();
@th3d0g
th3d0g / gist:d1767895658a6d2c22ed
Created February 22, 2016 21:32
Get Mime Type without FileInfo extension.
// Fix; check mime type without FileInfo extension.
if (function_exists('finfo_file')) {
$mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
} else {
$infFil=getimagesize($path);
$mime = $infFil["mime"];
}
Debug:
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
Release:
keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64
@th3d0g
th3d0g / functions.php
Created November 6, 2015 00:15 — forked from jameskoster/functions.php
WooCommerce - Exclude products from a particular category on the shop page
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() && is_shop() ) {
$q->set( 'tax_query', array(array(