Skip to content

Instantly share code, notes, and snippets.

View NoTimeForHero's full-sized avatar

NoTimeForHero

View GitHub Profile
@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'],
@NoTimeForHero
NoTimeForHero / gist:f50524c07f121f47e9fc
Created March 2, 2015 19:38
Get ID from Ammy Admin
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
BOOL CALLBACK FindAmmy(HWND hwnd, LPARAM lParam);
BOOL CALLBACK FindAmmyChilds(HWND hwnd, LPARAM lParam);
const char* getAmmyData();
const char* AMMY_WIN_NAME = "Ammyy Admin v3.5";