Skip to content

Instantly share code, notes, and snippets.

View par6n's full-sized avatar

Ehsaan par6n

  • The Netherlands
View GitHub Profile
@par6n
par6n / netstat.js
Created April 16, 2016 18:17
This is a dead simple NodeJS code that extracts netstat information and prints them out. Worked on Windows 10, 8.1 and 8
function netstat( cb ) {
const spawn = require( 'child_process' ).spawn;
const netstat = spawn( 'netstat', [ '-e' ] );
var resp = '';
netstat.stdout.on( 'data', ( data ) => {
resp += data.toString();
} );
netstat.stdout.on( 'end', ( data ) => {
@par6n
par6n / 1st challenge results.md
Last active July 6, 2016 16:27
1st challenge results (telegram.me/code_challenges)
@par6n
par6n / index.js
Created April 20, 2016 17:09
An inline bot for formatting text
var TelegramBot = require( 'node-telegram-bot-api' );
var token = 'XXXX';
var bot = new TelegramBot( token, { polling: true } );
var formats = {};
var waitingFor = {};
var messageText = {};
bot.on( 'inline_query', function( query ) {
if ( query.query == '' ) return;
@par6n
par6n / shuffle.php
Last active December 16, 2015 08:09
str_shuffle(); A shorthand for generating random strings.
<?php
echo str_shuffle('ABCDEFGH');
// may returns HGACBDEF
// unicode shuffle (qeremy [atta] gmail [dotta] com)
function str_shuffle_unicode($str) {
$tmp = preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
shuffle($tmp);
return join("", $tmp);
}
<?php
$a = array( 'a', 'e', 'i', 'o', 'u' );
$b = array( 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z' );
for( $i = 0; $i <= 20; $i++ ) {
shuffle($a);
shuffle($b);
echo $b[0];
echo $a[0];