Skip to content

Instantly share code, notes, and snippets.

View ekinhbayar's full-sized avatar

Ekin ekinhbayar

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ekinhbayar on github.
  • I am ekin (https://keybase.io/ekin) on keybase.
  • I have a public key whose fingerprint is D914 5696 5899 81E2 3509 E155 7625 F1AC 8203 700E

To claim this, I am signing this object:

@ekinhbayar
ekinhbayar / string.c
Last active August 17, 2016 09:28
stupid xor swap try
PHP_FUNCTION(strrev)
{
zend_string *str;
char *e, *p;
zend_string *n;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &str) == FAILURE) {
return;
}
@ekinhbayar
ekinhbayar / PHPSrcGrok.php
Last active September 4, 2016 23:53
Changes to lxr plugin
<?php declare(strict_types = 1);
namespace Room11\Jeeves\Plugins;
use Amp\Artax\Cookie\Cookie;
use Amp\Artax\Cookie\CookieJar;
use Amp\Artax\HttpClient;
use Amp\Artax\Request as HttpRequest;
use Amp\Artax\Response as HttpResponse;
use Amp\Artax\Uri;
@ekinhbayar
ekinhbayar / 100_doors.md
Last active September 7, 2016 20:34
Interpreting 100 doors problem

100 Doors Problem

Note: This is more of a math problem than an algorithm, yet it's a nice, fun one to play with, so I'm going for it.

Problem:

You have 100 doors in a row that are all initially closed. You make 100 passes by the doors.

The first time through, you visit every door and toggle the door (if the door is closed, you open it; if it is open, you close it). The second time you only visit every 2nd door (#2, #4, #6, ...). The third time, every 3rd door (#3, #6, #9, ...), etc, until you only visit the 100th door.

@ekinhbayar
ekinhbayar / getSeconds.php
Last active September 11, 2016 20:51
Pass time and get result in seconds
function getSeconds(string $time){ // $time is either 18:00 or "2 hours"
if(preg_match("/(2[0-3]|[01][0-9]):([0-5][0-9])/", $time)){ // ^
$format = 'Y-m-d H:i:s';
$now = new \DateTimeImmutable();
$future = new \DateTimeImmutable(date($format, strtotime($time)));
$h = ( ($t = $future->format('H')) == '00') ? 24 : $t;
$f = ( ($z = $now->format('H')) == '00') ? 24 : $z;
$d = $h - $f;
return $d * 3600 ?? false;
}
This file has been truncated, but you can view the full file.
! !
# #
$ $
% NN JJ VB SYM
%... :
%CHG NN
& CC NNP SYM
( (
) )
* SYM , :
@ekinhbayar
ekinhbayar / brown-taggedwords.py
Created October 16, 2016 11:34 — forked from ulgens/brown-taggedwords.py
Export Brown Corpus tagged words by categories using NLTK. Based on: https://gist.github.com/JonathanReeve/ac543e9541d1647c1c3b
from nltk.corpus import brown
for category in brown.categories():
words = brown.tagged_words(categories=category)
text = '\n '.join('%s, %s' % word for word in words)
filename = category + '.txt'
with open(filename, 'w') as outfile:
outfile.write(text)
@ekinhbayar
ekinhbayar / brown_lexicon.txt
Created October 16, 2016 14:51
Lexicon generated from brown corpus categories using python nltk. Still needs to be deduped (keeping tags)!
This file has been truncated, but you can view the full file.
!, .
!, .-HL
&, CC
&, CC-HL
&, CC-TL
&, NP-TL
'', ''
', '
'13, CD
'20's, NNS
@ekinhbayar
ekinhbayar / brown_tagged.py
Created October 16, 2016 23:43
Better formatted
from nltk.corpus import brown
for category in brown.categories():
words = brown.tagged_words(categories=category)
text = '\n'.join('%s %s' % word for word in words)
filename = category + '.txt'
with open(filename, 'w') as outfile:
outfile.write(text)
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*.php]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true