Skip to content

Instantly share code, notes, and snippets.

View tim-hub's full-sized avatar
:octocat:
Patience is Love

Tim tim-hub

:octocat:
Patience is Love
View GitHub Profile
@tim-hub
tim-hub / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@tim-hub
tim-hub / springer-free-maths-books.md
Created December 29, 2015 04:08 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
@tim-hub
tim-hub / AutoSnap.cs
Created January 8, 2016 03:32 — forked from estebanpadilla/AutoSnap.cs
Auto snap to grid in Unity If you need to auto snap a gameObject to the grid in unity this script will help you. Usage: Create a Editor folder in your assets folder. Add the AutoSnap.cs script to the Editor folder. To open press Command + L (Mal), Control + L (PC) Source: http://answers.unity3d.com/questions/148812/is-there-a-toggle-for-snap-to-…
using UnityEngine;
using UnityEditor;
public class AutoSnap : EditorWindow
{
private Vector3 prevPosition;
private bool doSnap = true;
private float snapValue = 1;
[MenuItem( "Edit/Auto Snap %_l" )]
@tim-hub
tim-hub / check long press.cs
Created April 7, 2016 06:21
check long press on touch screen
bool CheckForLongPress() {
if (Input.touches[0].phase == TouchPhase.Began) { // If the user puts her finger on screen...
_timePressed = Time.time - _timeLastPress;
}
if (Input.touches[0].phase == TouchPhase.Ended) { // If the user raises her finger from screen
_timeLastPress = Time.time;
if (_timePressed > WaitingSeconds/2f) { // Is the time pressed greater than our time delay threshold?
return true;
}
@tim-hub
tim-hub / AssetBundleSample.cs
Created April 18, 2016 03:43 — forked from yaeda/AssetBundleSample.cs
Unity AssetBundle Examples.
using System;
using UnityEngine;
using System.Collections;
public class AssetBundleSample : MonoBehaviour {
public GUIText guitext;
// Use this for initialization
void Start () {
// Copyright (c) 2012 Calvin Rien
// http://the.darktable.com
//
// This software is provided 'as-is', without any express or implied warranty. In
// no event will the authors be held liable for any damages arising from the use
// of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
@tim-hub
tim-hub / MiniJSON.cs
Created May 31, 2016 10:25 — forked from darktable/MiniJSON.cs
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2013 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
using System.Net;
public string GetHtmlFromUri(string resource)
{
string html = string.Empty;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(resource);
try
{
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
bool isSuccess = (int)resp.StatusCode < 299 && (int)resp.StatusCode >= 200;
@tim-hub
tim-hub / ARKeySetter Intro.md
Created August 26, 2016 04:07
This script is for vuforia to set the vuforia api key.

If you want to set the key, but not want to share the key to the public, you need this.

  1. put it on ARCamera, and give it the first priority in components
  2. put your key as apiKey.txt file in Builds folder
@tim-hub
tim-hub / detect.py
Created December 19, 2016 22:45 — forked from LeZuse/detect.py
Flask browser detection
browser = request.user_agent.browser
version = request.user_agent.version and int(request.user_agent.version.split('.')[0])
platform = request.user_agent.platform
uas = request.user_agent.string
if browser and version:
if (browser == 'msie' and version < 9) \
or (browser == 'firefox' and version < 4) \
or (platform == 'android' and browser == 'safari' and version < 534) \
or (platform == 'iphone' and browser == 'safari' and version < 7000) \