Skip to content

Instantly share code, notes, and snippets.

View hengkiardo's full-sized avatar

Hengki Sihombing hengkiardo

  • Jakarta, Indonesia
View GitHub Profile
@hengkiardo
hengkiardo / javascriptMD5.js
Created June 27, 2012 05:32
MD5 With JavaScript
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 July 30, 2012 08:30
Grow Image when Hover
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 September 4, 2012 11:24 — forked from og-shawn-crigger/controller.php
Valums AJAX File Uploader for CodeIgniter
<?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
@hengkiardo
hengkiardo / jqcookies.js
Created September 6, 2012 08:57
Jquery Cookie
(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 September 21, 2012 09:12 — forked from mfkp/index.html
mailchimp ajax signup form example
<!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 September 21, 2012 10:53
JavaScript Money Format
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) : "");
@hengkiardo
hengkiardo / google-drive-upload-pdf.php
Created October 2, 2012 08:52 — forked from hubgit/google-drive-upload-pdf.php
Upload a PDF file to Google Drive
<?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 October 3, 2012 07:33
Convert simple array into two-dimensional array(matrix) in javascript
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 October 5, 2012 05:35
A simple helper to extract values from a string based on a pattern.
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 October 19, 2012 11:27
WordPress like option feature for your CodeIgniter application
<?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,