Skip to content

Instantly share code, notes, and snippets.

@avil13
avil13 / jdecoder json decode
Created September 1, 2013 20:38
PHP jdecoder
<?php
function jdecoder($json_str) {
$cyr_chars = array (
'\u0430' => 'а', '\u0410' => 'А',
'\u0431' => 'б', '\u0411' => 'Б',
'\u0432' => 'в', '\u0412' => 'В',
'\u0433' => 'г', '\u0413' => 'Г',
'\u0434' => 'д', '\u0414' => 'Д',
'\u0435' => 'е', '\u0415' => 'Е',
  1. Open Terminal move to your home folder: cd ~

  2. Enable git colors: git config --global color.ui true

  3. Make a file called ".colors": touch .colors

  4. Open .colors and paste the following:

@avil13
avil13 / myCookie.js
Last active December 27, 2017 15:59
JavaScript cookie function
/**
* myCookie('test', 123123) // set cookie
* myCookie('test') // get cookie
* myCookie('test', false) // delete cookie
*/
function myCookie(name, value) {
name = encodeURIComponent(name);
if (value === undefined) {
@avil13
avil13 / fancyAlert.js
Last active August 29, 2015 14:05
fancy alert
function fancyAlert(msg) {
jQuery.fancybox({
'modal' : true,
'content' : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input style=\"margin:3px;padding:0px;\" type=\"button\" onclick=\"jQuery.fancybox.close();\" value=\"Ok\"></div></div>"
});
}
function fancyConfirm(msg,callback) {
var ret;
jQuery.fancybox({
@avil13
avil13 / 0_reuse_code.js
Last active August 29, 2015 14:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@avil13
avil13 / jsonp.php
Last active August 29, 2015 14:14 — forked from cowboy/jsonp.php
<?PHP
# JSONP "callback" param explanation, via basic PHP script.
#
# "Cowboy" Ben Alman
# http://benalman.com/
# Set $data to something that will be serialized into JSON. You'll undoubtedly
# have your own code for this.
$data = array("some_key" => "some_value");
{"lastUpload":"2017-10-24T13:19:40.881Z","extensionVersion":"v2.8.3"}
// Для вызова функции не чаще чем в указанный интервал времени
var my_debounce = function(func, wait) {
var timeout;
return function() {
var context = this,
args = arguments,
later = function() {
timeout = null;
func.apply(context, args);
};
@avil13
avil13 / cors-nginx.conf
Created May 24, 2016 13:57 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@avil13
avil13 / PhoneCodesDictionary.js
Created June 15, 2016 10:07
PhoneCodesDictionary
Account.constant('PhoneCodesDictionary', [
{ "mask": "+247-####", "cc": "AC", "name_en": "Ascension", "desc_en": "", "name_ru": "Остров Вознесения", "desc_ru": "" },
{ "mask": "+376-###-###", "cc": "AD", "name_en": "Andorra", "desc_en": "", "name_ru": "Андорра", "desc_ru": "" },
{ "mask": "+971-5#-###-####", "cc": "AE", "name_en": "United Arab Emirates", "desc_en": "mobile", "name_ru": "Объединенные Арабские Эмираты", "desc_ru": "мобильные" },
{ "mask": "+971-#-###-####", "cc": "AE", "name_en": "United Arab Emirates", "desc_en": "", "name_ru": "Объединенные Арабские Эмираты", "desc_ru": "" },
{ "mask": "+93-##-###-####", "cc": "AF", "name_en": "Afghanistan", "desc_en": "", "name_ru": "Афганистан", "desc_ru": "" },
{ "mask": "+1(268)###-####", "cc": "AG", "name_en": "Antigua & Barbuda", "desc_en": "", "name_ru": "Антигуа и Барбуда", "desc_ru": "" },
{ "mask": "+1(264)###-####", "cc": "AI", "name_en": "Anguilla", "desc_en": "", "name_ru": "Ангилья", "desc_ru": "" },