Skip to content

Instantly share code, notes, and snippets.

View detectLocalIps.js
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++) {
View dima.js
const dima = "cool man";
@knyga
knyga / StashDriverFactoryTest.php
Created Mar 17, 2017
StashDriverFactoryTest.php
View StashDriverFactoryTest.php
<?php
namespace WebExtractor\Test;
use WebExtractor\StashDriverFactory\StashDriverFactory;
/**
* Class StashDriverFactoryTest
*
View html
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 Jan 7, 2015
Automatically reconnects to wifi
View Wifi checker
@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
Armor-games ссылочные блоки
View gist:b94cf4a11f39c9ee8f8f
<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>
View gist:7ab58c1608423fb5924e
<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>
View Shaman handout view data example
{
"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,
View gist:11175250
#!/bin/sh
DateDir=`date +"%d.%m.%Y"`
createdir()
{
if [ ! -d $1 ]
then
mkdir $1
fi
}
@knyga
knyga / gist:9558652
Created Mar 14, 2014
Freelansim.ru, get emails by keyword [outofdate]
View gist:9558652
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;
}
};