Skip to content

Instantly share code, notes, and snippets.

Hengki Sihombing hengkiardo

  • Jakarta, Indonesia
View GitHub Profile
View javascriptMD5.js
var MD5 = function (string) {
function RotateLeft(lValue, iShiftBits) {
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
}
function AddUnsigned(lX,lY) {
var lX4,lY4,lX8,lY8,lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
@hengkiardo
hengkiardo / growImage.js
Created Jul 30, 2012
Grow Image when Hover
View growImage.js
function growImage() {
$('a.idea-link').each(function () {
var oheight = $(this).children(0).height();
var owidth = $(this).children(0).width();
var nheight = (oheight + (oheight * 0.25));
var nwidth = (owidth + (owidth * 0.25));
var top = ((oheight - nheight) / 2);
var left = ((owidth - nwidth) / 2);
$(this).mouseenter(function () {
$(this).css('z-index', '2').children(0).css('z-index', '3').stop().animate({
@hengkiardo
hengkiardo / controller.php
Created Sep 4, 2012 — forked from svizion/controller.php
Valums AJAX File Uploader for CodeIgniter
View controller.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ajax_uploader extends CI_Controller {
// ------------------------------------------------------------------------
/**
* Array of allowed file extensions to upload.
*
* @var array
View jqcookies.js
(function ($, document, undefined) {
var pluses = /\+/g;
function raw(s) {
return s;
}
function decoded(s) {
return decodeURIComponent(s.replace(pluses, ' '));
}
$.cookie = function (key, value, options) {
@hengkiardo
hengkiardo / index.html
Created Sep 21, 2012 — forked from mfkp/index.html
mailchimp ajax signup form example
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.ketchup.all.min.js" type="text/javascript"></script>
</head>
<body>
<div id="email">
<span>Enter your email to sign up</span>
<form action="/subscribe.php" id="invite" method="POST">
@hengkiardo
hengkiardo / money-format.js
Created Sep 21, 2012
JavaScript Money Format
View money-format.js
Number.prototype.formatMoney = function(places, symbol, thousand, decimal) {
places = !isNaN(places = Math.abs(places)) ? places : 2;
symbol = symbol !== undefined ? symbol : "$";
thousand = thousand || ",";
decimal = decimal || ".";
var number = this,
negative = number < 0 ? "-" : "",
i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
View google-drive-upload-pdf.php
<?php
require 'google-api/apiClient.php';
require 'google-api/contrib/apiOauth2Service.php';
require 'google-api/contrib/apiDriveService.php';
$pdfFile = 'test.pdf';
// API Console: https://code.google.com/apis/console/
// Create an API project ("web applications") and put the client id and client secret in config.ini.
@hengkiardo
hengkiardo / convert-array.js
Created Oct 3, 2012
Convert simple array into two-dimensional array(matrix) in javascript
View convert-array.js
function listToMatrix(list, elementsPerSubArray) {
var matrix = [], i, k;
for (i = 0, k = -1; i < list.length; i++) {
if (i % elementsPerSubArray === 0) {
k++;
matrix[k] = [];
}
matrix[k].push(list[i]);
}
return matrix;
@hengkiardo
hengkiardo / extract_values.js
Created Oct 5, 2012
A simple helper to extract values from a string based on a pattern.
View extract_values.js
var extractValues = function(str, pattern, options) {
options = options || {};
var delimiters = options.delimiters || ["{", "}"];
var lowercase = options.lowercase;
var whitespace = options.whitespace;
var special_chars_regex = /[\\\^\$\*\+\.\?\(\)]/g;
var token_regex = new RegExp( delimiters[0] + "([^" + delimiters.join("") + "\t\r\n]+)" + delimiters[1], "g");
var tokens = pattern.match(token_regex);
var pattern_regex = new RegExp(pattern.replace(special_chars_regex, "\\$&").replace(token_regex, "(\.+)"));
@hengkiardo
hengkiardo / option_helper
Created Oct 19, 2012
WordPress like option feature for your CodeIgniter application
View option_helper
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
Opions Helper for CodeIgniter
Database Table for this Helper:
CREATE TABLE IF NOT EXISTS `tbl_option` (
`option_id` bigint(20) NOT NULL AUTO_INCREMENT,
You can’t perform that action at this time.