Skip to content

Instantly share code, notes, and snippets.

Avatar

Ehsaan par6n

View GitHub Profile
View Good words
<?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];
@par6n
par6n / shuffle.php
Last active Dec 16, 2015
str_shuffle(); A shorthand for generating random strings.
View shuffle.php
<?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);
}
@par6n
par6n / index.js
Created Apr 20, 2016
An inline bot for formatting text
View index.js
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 / 1st challenge results.md
Last active Jul 6, 2016
1st challenge results (telegram.me/code_challenges)
View 1st challenge results.md
@par6n
par6n / netstat.js
Created Apr 16, 2016
This is a dead simple NodeJS code that extracts netstat information and prints them out. Worked on Windows 10, 8.1 and 8
View netstat.js
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 / index.js
Created Jan 13, 2017
@Link4FileBot
View index.js
const Telegraf = require( 'telegraf' ),
request = require( 'request' ),
Token = 'TOKEN HERE',
currentUsers = {},
messages = {},
Bot = new Telegraf( Token );
Bot.command( 'start', ( ctx ) => {
ctx.replyWithHTML( `<b>Send/Forward me your files to get the direct link for it.</b>
Powered by @pwrtelegram` );
@par6n
par6n / msub.sh
Created May 5, 2017
Subtitles merge
View msub.sh
#!/bin/bash
mkdir -p Output
for f in *.mkv
do
filename="${f%.*}"
echo "Proccessing ${filename}.mkv"
if [ ! -f "${filename}.srt" ]; then
@par6n
par6n / gulpfile.js
Created Aug 3, 2015
Git handler through Gulp, read hive.ir or contact me for more details.
View gulpfile.js
// Example for handling git through gulp. Useful receipt for sometimes ;)
// hive.ir - made by Ehsaan <iehsan.ir@gmail.com>
// gulpfile.js
var gulp = require( 'gulp' );
var git = require( 'gulp-git' );
var minifyCss = require( 'gulp-minify-css' );
var uglify = require( 'gulp-uglify' );
var concat = require( 'gulp-concat' );
var fs = require( 'fs' );
View keybase.md

Keybase proof

I hereby claim:

  • I am blacksuited on github.
  • I am ehsaan_me (https://keybase.io/ehsaan_me) on keybase.
  • I have a public key ASAvkWorqhcbwzf6gYedoAxccOazv5xy_Yc9-_MMo0YXlgo

To claim this, I am signing this object:

View words.go
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
fields := strings.Fields( s )
output := map[string]int{}