Skip to content

Instantly share code, notes, and snippets.

View lnked's full-sized avatar
🧠
I may be slow to respond.

Edik Bulikyan lnked

🧠
I may be slow to respond.
View GitHub Profile
@vpArth
vpArth / dripstat
Last active August 29, 2015 14:00
function Miner(incr, dripK, delay) {
var that = this;
this.incr = incr || localStats.bps*1e3;
this.dripK = dripK || 0.5;
this.delay = delay || 100;
document.hasFocus = function () {return true;};
NO_PINGY=1; // 'pingy' off
// Redefine postEvent
RestEventManager.prototype.postEventData = function(e,t,next)
@kissarat
kissarat / descend.sql
Created June 16, 2015 01:30
MySQL. Gets all descendants (children) for given ID of parent with depth parameter
DROP PROCEDURE IF EXISTS descend;
CREATE PROCEDURE descend(uid INT, depth INT) BEGIN
DROP TABLE IF EXISTS descendants;
DROP TABLE IF EXISTS children;
CREATE TEMPORARY TABLE descendants (
id int,
parent_id int,
level int
) ENGINE = MEMORY;
INSERT INTO descendants(id, level)
@asm0dey
asm0dey / Iterables.es6.js
Last active March 6, 2016 10:14
Simple library with lazy es6 iterables. If you use es5 - don't forget to add es5 polyfill
function range(start, finish, step = 1) {
if (step < 1) throw "Step must be ge 1"
return {
[Symbol.iterator]: function* () {
let count = 1;
yield start
if (start !== finish) {
let tmp = start;
if (start < finish) {
while (tmp < finish) {
@jakebellacera
jakebellacera / force_new_tab.php
Last active June 3, 2016 01:24
Force PDF links to open in a new tab in PHP.
$new_text = preg_replace(
'/((<a (?=.*\.pdf)(?!.*target="_blank").*?)>)/',
'$2 target="_blank">',
$old_text
);
@MrRoyce
MrRoyce / gist:280063164a5f744cb0ec3ecc36be84a7
Last active April 28, 2017 20:26
webpack.config.js to debug problem with Module not found: Error: Cannot resolve module 'babel-runtime'
/**
* @Author: Royce
* @Date: 2016-06-12T10:54:44-04:00
* @Email: rharding@tonight.com
* @Project: Tonight
* @Last modified by: royce
* @Last modified time: 2016-09-23T19:58:59-04:00
* @License: © 2016 Tonight LLC All Rights Reserved
*/
@crucialfelix
crucialfelix / AsyncComponent.tsx
Created July 27, 2017 13:32
TypeScript port of react-loadable
/**
* A port, cleanup and simplification of https://github.com/thejameskyle/react-loadable
* MIT License Copyright 2017 Chris Sattinger
*/
import React from "react";
export function Loading({ loading = true }) {
return loading
? <i className="fa fa-spinner fa-spin" aria-hidden="true" />
: null;
@umidjons
umidjons / pub-sub.php
Created January 13, 2014 09:15
PubSub pattern / Events in PHP
<?php
// more: http://baylorrae.com/php-pubsub/
class PubSub
{
private static $events = array(); // all subscriptions
// Don't allow PubSub to be initialized outside this class
@oslego
oslego / gist:f13e136ffeaa6174289a
Last active January 3, 2019 14:24 — forked from sl4m/gist:5091803
create self-signed certificate for localhost
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@monolithed
monolithed / jest.md
Last active January 3, 2019 17:41
Почему Jest вызывает боль!

Причины, по которым мне не правится Jest

  • Нельзя задать директорию для снепшотов. На первый взгляд это не кажется проблемой, но когда вы начнете создавать файлики с постфиксом .spec.js, то на каждом уровне у вас будут папки __snapshots__. Представьте, что открываете вы директорию, а там папка с кешом, открываете другую и там тоже самое — жуть!

  • testPathDirs не поддерживает glob-паттерн.

  • Jest как и Webpack 2 валидирует все поля. Это означает, что подключив какой-то сторонний препроцессор вы должны описывать его конфигурацию в вашем package.json, и даже не в секции jest, поскольку она там тоже валидируется!

  • setupFiles включаются в набор тестов, если они попадают в testPathDirs.

@Stubbs
Stubbs / main.yml
Created March 28, 2015 14:31
Ansible Playbook to install PHP7
- name: Install Packages Needed To Compile PHP 7
apt: pkg={{ item }} state=latest
with_items:
- git
- autoconf
- bison
- libxml2-dev
- libbz2-dev
- libmcrypt-dev
- libcurl4-openssl-dev