Skip to content

Instantly share code, notes, and snippets.

@fuhoi
fuhoi / gist:1050233
Created June 28, 2011 00:48
html-set-homepage
<html>
<head>
<title>JavaScript - Set Homepage</title>
</head>
<body>
<input type="button" value="Set homepage" onclick="setHomepage('http://www.google.com');" />
<script language="javascript">
function setHomepage(url) {
if (document.all) {
document.body.style.behavior='url(#default#homepage)';
@fuhoi
fuhoi / xmlHttpRequest.html
Created June 28, 2011 04:16
javascript-xmlhttp-request
<html>
<head>
<title>JavaScript - Xml Http Request</title>
</head>
<body>
<input type="button" value="Xml Http Request" onclick="requestFile();" />
<script language="javascript">
// Source: http://www.webdeveloper.com/forum/showthread.php?t=147342
function requestFile(){
@fuhoi
fuhoi / gist:1050486
Created June 28, 2011 04:24
javascript-set-homepage
function setHomepage(url) {
if (document.all) {
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(url);
} else if (window.sidebar) {
if (window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch(e) {
alert("Cannot set homepage deu to browser permissions. Enter website manually or if you wish to enable this functionality, enter about:config in your address bar and change the value of signed.applets.codebase_principal_support to true");
@fuhoi
fuhoi / gist:1050495
Created June 28, 2011 04:29
javascript-ie-mode
/* JavaScript to determine browser mode */
function getEngine(){
var _eng;
if(window.navigator.appName=="Microsoft Internet Explorer"){ // This is an IE browser. What mode is the engine in?
if(document.documentMode){ // IE8 or later
_eng = document.documentMode;
} else { // IE 5-7
_eng = 5; // Assume quirks mode unless proven otherwise
if(document.compatMode){
if(document.compatMode == "CSS1Compat") {
@fuhoi
fuhoi / gist:1050557
Created June 28, 2011 05:32
html-add-to-favourites
<html>
<head>
<title>JavaScript - Add to favourites</title>
</head>
<body>
<input type="button" value="Add to favourites" onclick="addToFavorites('Google','http://www.google.com');" />
<script language="javascript">
function addToFavorites(name,url) {
if(window.external){ // ie
window.external.AddFavorite(url,name)
/*
* jQuery scrollbarTable - v0.1 - 5/6/2011
* Derek Bredensteiner
* Licensed under the MIT license http://www.opensource.org/licenses/mit-license.php
*/
(function($){
$.fn.scrollbarTable = function(i){
var o = {};
if(typeof(i)=='number')o.height=i;
else if(typeof(o)=='object') o = i;
@fuhoi
fuhoi / html-twitter-widget
Created December 22, 2011 04:06
Twitter Widget
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: 4,
interval: 30000,
width: 250,
height: 300,
theme: {
@fuhoi
fuhoi / android snippets.md
Last active July 13, 2023 14:46
Android Snippets

ANDROID SNIPPETS

  • This is a collection of android snippets
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#fde0dc</color>
<color name="md_red_100">#f9bdbb</color>
<color name="md_red_200">#f69988</color>