Skip to content

Instantly share code, notes, and snippets.

View knyga's full-sized avatar
🇺🇦

Oleksandr Knyga knyga

🇺🇦
View GitHub Profile
function detectLocalIps() {
const networkInterfaces = require('os').networkInterfaces();
return Object.keys(networkInterfaces).reduce((acc, interfaceKey) => {
const filterIpsList = ['127.0.0.1', '::'];
const interfaceDetails = networkInterfaces[interfaceKey];
for(let i=0; i<interfaceDetails.length; i++) {
const locator = interfaceDetails[i];
if(locator && locator.hasOwnProperty('address') && locator.hasOwnProperty('family') && locator.family === 'IPv4') {
let isAllowed = true;
for(let j=0; isAllowed && j < filterIpsList.length; j++) {
@knyga
knyga / dima.js
Created March 17, 2017 21:57
dima.js
const dima = "cool man";
@knyga
knyga / StashDriverFactoryTest.php
Created March 17, 2017 21:57
StashDriverFactoryTest.php
<?php
namespace WebExtractor\Test;
use WebExtractor\StashDriverFactory\StashDriverFactory;
/**
* Class StashDriverFactoryTest
*
const express = require(‘express’);
const app = express();
const http = require(‘http’).Server(app);
const io = require(‘socket.io’)(http);
// middleware for static processing
app.use(express.static(__dirname + ‘/static’));
// web socket connection event
io.on(‘connection’, function(socket){
console.log(‘connection’);
});
@knyga
knyga / Wifi checker
Created January 7, 2015 11:15
Automatically reconnects to wifi
@set @x=0; /*
@echo off
SetLocal EnableDelayedExpansion
ver |>NUL find "6." && if "%1" neq "Admin" (
cscript.exe //nologo //e:jscript "%~f0"
Exit
)
:begin
@knyga
knyga / gist:b94cf4a11f39c9ee8f8f
Created May 10, 2014 21:34
Armor-games ссылочные блоки
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Armor-games -->
<ins class="adsbygoogle"
style="display:inline-block;width:468px;height:15px"
data-ad-client="ca-pub-0350114752821968"
data-ad-slot="1243309512"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
@knyga
knyga / gist:7ab58c1608423fb5924e
Created May 10, 2014 15:57
Armor-games - 336x280
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Armorgames, 336x280 -->
<ins class="adsbygoogle"
style="display:inline-block;width:336px;height:280px"
data-ad-client="ca-pub-0350114752821968"
data-ad-slot="3675840310"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{
"id": 2,
"name": "Death Star",
"thumb": "/uploads/slides/thumbs/1131.png",
"onCreated": 1398222222,
"onUpdated": 1398249206,
"onPublished": 1398258112,
"author": "Oleksandr Knyga",
"editor": "Marjam Holy",
"startState": 11,
#!/bin/sh
DateDir=`date +"%d.%m.%Y"`
createdir()
{
if [ ! -d $1 ]
then
mkdir $1
fi
}
@knyga
knyga / gist:9558652
Created March 14, 2014 22:50
Freelansim.ru, get emails by keyword [outofdate]
var request = "http://freelansim.ru/freelancers?freeonly=true&page=<?%page%?>&q=ruby+on+rails",
pcount = $('.gap').next().text() || 5,
emails = [];
var stat = {
cur: 0,
total: 0,
left: function() {
return this.total - this.cur;
}
};