Skip to content

Instantly share code, notes, and snippets.

View kidker's full-sized avatar
🎯
Focusing

kidker kidker

🎯
Focusing
View GitHub Profile
@kidker
kidker / json
Created December 1, 2016 21:32
isoCapitals
let isoCapitals: any = {
"ru": {
address: 'Москва',
latitude: 55.755826,
longitude: 37.617300
},
"ca": {
address: 'Ottawa',
latitude: 45.421530,
longitude: -75.697193
@kidker
kidker / javascript
Created September 14, 2016 20:13
Work with cookie
var docCookies = {
getItem: function (sKey) {
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
},
setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
var sExpires = "";
if (vEnd) {
switch (vEnd.constructor) {
case Number:
@kidker
kidker / php
Created August 2, 2016 06:42
Curl Send File
http://blog.derakkilgo.com/2009/06/07/send-a-file-via-post-with-curl-and-php/
$file_name_with_full_path = realpath('./sample.jpeg');
$post = array('extra_info' => '123456','file_contents'=>'@'.$file_name_with_full_path);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
curl_close ($ch);
@kidker
kidker / regexp
Created August 1, 2016 19:23
regexp tppabs remove
/tppabs=".+[.]css"/ig
@kidker
kidker / 1 px
Created July 18, 2016 20:01
1 px PHP
Transparent 1x1 PNG:
header('Content-Type: image/png');
echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=');
//////
Transparent 1x1 GIF:
header('Content-Type: image/gif');
@kidker
kidker / script.js
Created July 13, 2016 10:48
Instagram: get all feed by user
Point: https://www.instagram.com/USER_LOGIN/media/
Return: JSON format
/**
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
* @param obj1
* @param obj2
* @returns obj3 a new object based on obj1 and obj2
*/
function merge_options(obj1,obj2){
var obj3 = {};
for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
@kidker
kidker / uri.js
Created June 25, 2016 16:57 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@kidker
kidker / Async function with callback
Created June 3, 2016 15:53
Async function with callback
down vote
accepted
Thanks RASG for http://stackoverflow.com/a/3211647/982924
Async function with callback:
function async(u, c) {
var d = document, t = 'script',
o = d.createElement(t),