Skip to content

Instantly share code, notes, and snippets.

@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) );
@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 / 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 / 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 / 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 / gist:8067fb45ec6429dd92c554274f4670b2
Created March 6, 2018 01:14 — forked from snowman-repos/gist:3825198
JavaScript: Detect Orientation Change on Mobile Devices
// Listen for orientation changes
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
alert(window.orientation);
}, false);
// Listen for resize changes
window.addEventListener("resize", function() {
// Get screen size (inner/outerWidth, inner/outerHeight)
@th3d0g
th3d0g / typescript_enum_flag.ts
Last active November 18, 2018 12:37
Example of using Enum Flags in TypeScript.
// They're a way to efficiently store and represent a collection of boolean values. -->
//For example, taking this flags enum:
enum Traits {
None = 0,
Friendly = 1 << 0, // 0001 -- the bitshift is unnecessary, but done for consistency
Mean = 1 << 1, // 0010
Funny = 1 << 2, // 0100
Boring = 1 << 3, // 1000
@th3d0g
th3d0g / RoundToHalf.js
Created January 22, 2019 00:20
Created with Copy to Gist
function roundToHalf(value) {
   var converted = parseFloat(value); // Make sure we have a number
   var decimal = (converted - parseInt(converted, 10));
   decimal = Math.round(decimal * 10);
   if (decimal == 5) { return (parseInt(converted, 10)+0.5); }
   if ( (decimal < 3) || (decimal > 7) ) {
      return Math.round(converted);
   } else {
      return (parseInt(converted, 10)+0.5);
   }
@th3d0g
th3d0g / awr_api.php
Created February 16, 2019 10:21
AWR API PHP
<?php
// AWR Functions //////////////
function awr_get( $action, $params = [] ){
$token = env('AWR_KEY');
$awr_url = env('AWR_URL');
$paramsString = "";
if( count($params) > 0 ){
@th3d0g
th3d0g / multiple_ssh_setting.md
Created April 1, 2019 11:42 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"