Skip to content

Instantly share code, notes, and snippets.

View ti-ka's full-sized avatar
🎯
Focusing

Tika Pahadi ti-ka

🎯
Focusing
View GitHub Profile
@ti-ka
ti-ka / Auto Write
Created April 11, 2015 00:21
Check if a variable is posted and show value
<?php
$items = array("name", "email","age"); //Assuming these fields
foreach($items as $item){
$val = (isset($_POST[$item])) ? $_POST[$item] : "";
//You might want to prevent MySQL injections by real_escape or use PDO prepare for safety.
echo "<input type='text' name='$item' value='$val' />";
}
?>
@ti-ka
ti-ka / index.html
Last active September 10, 2017 19:36
AJAX Rest API Call Sample - (response.json is the assumed file that API responds with)
<form onsubmit='APICall(); return false'>
<input type='search' placeholder='Enter Search Keyword' id="input" />
<input type='submit' value='Search'>
</form>
<!--Results will be here-->
<div id="show"></div>
<!--Include JQuery in the Site-->
<script src='https://code.jquery.com/jquery-2.1.4.min.js'></script>
var data = localStorage.getItem("savedData")
var request = $.ajax({
method : 'post',
data : {"name" : data}
url : "http://example.com/receive-data.php"
});
request.success(function(){
console.log("Data sent to server");
$("body").on("click", "#categoryNav>li>a", function () {
var item = $(this).attr("href");
var scrollTop = $(item).offset().top;
window.scrollTo(0, scrollTop - 100);
return false;
});
<?php
define("SERVER_INIT" , microtime(true));
if(!isset($_SESSION)){
session_start();
}
if( ! ini_get('date.timezone') )
@ti-ka
ti-ka / location.js
Last active December 3, 2015 20:11
// Run javascript after DOM is initialized
$(document).ready(function() {
var options = {
latitude: 30.5044,
longitude: -90.4656,
zoom: 16,
type: 'ROADMAP',
scrollwheel: false,
marker: {
@ti-ka
ti-ka / script.js
Created January 22, 2016 18:38
Sumleft
$("body").on("click", "td", function(){
$(this).html(parse($(this).html(), this));
})
function parse(str, _td){
return str.replace("=SUMLEFT()", sumLeft(_td))
}
function sumLeft(_td){
"use strict";
var ImageUploader = {
uploadURL : 'admin/inventory/uploadImage',
inputObject : document.getElementById('item-image-upload'),
uploadEntityName : "photos[]",
callback : function(response){
console.log(response);
},
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwkHBgoJCAkLCwoMDxkQDw4ODx4WFxIZJCAmJSMgIyIoLTkwKCo2KyIjMkQyNjs9QEBAJjBGS0U+Sjk/QD3/2wBDAQsLCw8NDx0QEB09KSMpPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT3/wAARCABzAXgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD2aql/qllpcJlv7qG3T1kYDP09a4Dxv4v8SadM8ENk2n2xOFucby/0boPp1rzW4uZryYzXM0k0rdXkYsfzNdFOg5K7ZhOuouyR6zqnxW0q1ymnwTXjj+LGxPzPP6Vyt/8AFLXbokWwt7RD/cTc35n/AArjKK6I0YLoc8q031Naf
0110010001100001011101000110000100111010011010010110110101100001011001110110010100101111011010100111000001100101011001110011101101100010011000010111001101100101001101100011010000101100001011110011100101101010001011110011010001000001010000010101000101010011011010110101101001001010010100100110011101000001010000100100000101010001010001010100000101011001010000010100001001100111010000010100000101000100001011110011001001110111010000100100010001000001010000010110111101001000010000100111011101101011010010000100001001100111011011110100101001000011010000010110101101001100010000110111011101101111010011010100010001111000011010110101000101000100011101110011010001001111010001000111100000110100010101110100011001111000010010010101101001001010010000110100000101101101010010100101001101001101011001110100100101111001010010010110111101001100010101000110101101110111010010110100001101101111001100100100101101111001010010010110101001001101011010110101000101111001010011100110101001110011001110010101000101000101010000100100000101001010