This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadScript(url, callback) | |
{ | |
// Adding the script tag to the head as suggested before | |
var head = document.getElementsByTagName('head')[0]; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = url; | |
// Then bind the event to the callback function. | |
// There are several events for cross browser compatibility. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('max_execution_time', 0); | |
set_time_limit(0); | |
for($i=0; $i<6000; $i++) { | |
file_put_contents("$i.png", file_get_contents("http://vk.com/images/stickers/$i/256.png")); | |
usleep(500000); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addClass(cls) { | |
this[0].classList.add(cls); | |
} | |
function removeClass(cls) { | |
this[0].classList.remove(cls); | |
} | |
function hasClass(cls) { | |
return this[0].classList.contains(cls); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from 'lodash' | |
export function debounceRequest({ context, cb, debounceId = 'debounceId', interval = 1000 }) { | |
const id = `__debounce__${ debounceId }__` | |
if(_.isFunction(cb)) { | |
context[id] && context[id].cancel() | |
context[id] = _.debounce(cb, interval, false) | |
context[id]() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="password" name="passwd" id="passwd" class="text" | |
onkeypress="if (event.keyCode==13) this.form.login_form.click()"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class DeepDiffMapper { | |
static VALUE_CREATED = 'created' | |
static VALUE_UPDATED = 'updated' | |
static VALUE_DELETED = 'deleted' | |
static VALUE_UNCHANGED = 'unchanged' | |
static map(obj1, obj2, changedOnly = true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Получение данных из тела запроса | |
function getFormData($method) { | |
// GET или POST: данные возвращаем как есть | |
if ($method === 'GET') return $_GET; | |
if ($method === 'POST') return $_POST; | |
// PUT, PATCH или DELETE | |
$data = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1. get inline svg element to output. | |
2. get svg source by XMLSerializer. | |
3. add name spaces of svg and xlink. | |
4. construct url data scheme of svg by encodeURIComponent method. | |
5. set this url to href attribute of some "a" element, and right click this link to download svg file. | |
*/ | |
//get svg element. | |
var svg = document.getElementById("svg"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//does not work with colors containing alpha | |
@function encodecolor($string) { | |
@if type-of($string) == 'color' { | |
$hex: str-slice(ie-hex-str($string), 4); | |
$string:unquote("#{$hex}"); | |
} | |
$string: '%23' + $string; | |
@return $string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@function color($color-name) { | |
@return var(--color-#{$color-name}); | |
} |
OlderNewer