Skip to content

Instantly share code, notes, and snippets.

View NoTimeForHero's full-sized avatar

NoTimeForHero

View GitHub Profile
@NoTimeForHero
NoTimeForHero / index.html
Last active July 2, 2019 14:48
Загрузчик однофайловых Vue компонентов, работающий в IE10 (с Promise полифиллом)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IE10 Compatibility Vue SFC Loader</title>
<script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
<script src="https://unpkg.com/promise-polyfill@8.1.3/dist/polyfill.min.js"></script>
</head>
<body>
@NoTimeForHero
NoTimeForHero / xpath.js
Created June 20, 2019 22:51
Сниппет для получения простого селектора XPATH по аналогии с querySelectorAll
document.xpathSelectorAll = (selector) => {
const nodes = document.evaluate(selector, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
return Array(nodes.snapshotLength).fill(1).map((x, id) => nodes.snapshotItem(id));
}
@NoTimeForHero
NoTimeForHero / client.js
Created May 30, 2019 14:09
Simple Hot-Reload server
const hotReload = (address, options = {}) => {
// Константы
const CONST_RELOAD_MESSAGE = 'HOT_RELOAD_NOW';
// Настройки
const reconnect_timeout = options.reconnect_timeout || 500;
const reconnect_tries = options.reconnect_tries || 5;
// Локальные переменные
let socket = null;
let current_tries = 0;
@NoTimeForHero
NoTimeForHero / overlay.cpp
Last active May 19, 2019 21:18
Semi-transparent overlay to show user that window is blocked
#include <windows.h>
#include <hbapi.h>
#include <vector>
#include <map>
#include <cstdlib>
typedef std::vector<HWND> HWND_ARRAY;
std::map<HWND, HWND_ARRAY*> arrOverlays;
std::map<HWND, HBRUSH> overlaysBrushes;
@NoTimeForHero
NoTimeForHero / client_lib.cpp
Created September 23, 2018 19:03
Crazy Code
// TODO: Refactor this file
// It looks like a codegenerated crazy boilerplate code.
#define _HB_API_INTERNAL_ 1
#include <hbapi.h>
#include <hbapierr.h>
#include <hbstack.h>
#include <windows.h>
#include <hbapiitm.h>
@NoTimeForHero
NoTimeForHero / config.php
Last active June 6, 2018 23:01
Simple website with 2 languages (using Twig, Phroute, php Gettext library)
<?php
require dirname(__FILE__). '/vendor/autoload.php';
use Gettext\Translator;
use Gettext\Translations;
$tplDir = dirname(__FILE__).'/templates/';
$tmpDir = dirname(__FILE__).'/tmp/cache/';
$loader = new Twig_Loader_Filesystem($tplDir);
@NoTimeForHero
NoTimeForHero / postgres.c
Created March 6, 2017 11:11
Harbour PostgreSQL LISTEN
HB_FUNC ( PQ_GET_NOTIFY ) // VAA 07.03.2017
{
const char *clisten = "LISTEN ";
PGconn * conn = hb_PGconn_par( 1 );
const char *source = hb_parcx( 2 );
HB_SIZE size = strlen(source);
char *channel;
// NetFrameworkChecker.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include "NetFrameworkChecker.h"
wstringstream logger;
bool need_log = true;
bool debug = true;
@NoTimeForHero
NoTimeForHero / DBFLib.cpp
Last active February 4, 2016 18:54
Ruby extension based on C++ xBase Library for DBF support
// Include the Ruby headers and goodies
//#include "ruby.h"
#include <xbase64/xbase64.h>
#include "ruby.h"
#include <iostream>
#include <sys/stat.h>
#include <map>
#include <string>
#include <vector>
#include <time.h>
@NoTimeForHero
NoTimeForHero / pastebincom.py
Created July 13, 2015 19:00
Command line pastebin
#!/usr/bin/python
import sys, os
import urllib, urllib2
Highlights = {
'bash' : ['*.sh','*.bash'],
'php' : ['*.php'],
'python' : ['*.python'],
'rails' : ['*.rb'],
'ruby' : ['Gemfile'],
'python' : ['*.py'],