Skip to content

Instantly share code, notes, and snippets.

View dogancelik's full-sized avatar

Doğan Çelik dogancelik

View GitHub Profile
@dogancelik
dogancelik / DecodeNDT.cs
Last active September 25, 2015 20:07
(C#) DecodeNDT
/*
* Project Name: DecodeNDT
* Descripton: Decodes NDT files from Atlantica Online
* Ported from Python to C# by Doğan Çelik
* Originally from: http://bit.ly/kilEew
*/
using System;
using System.Collections.Generic;
using System.Text;
@dogancelik
dogancelik / bolum.php
Last active October 2, 2015 13:28
(PHP) TheTVDB API Example
<?php
/*
* Written by: Doğan Çelik
* Description: Exports a list of episode names from a specified season from a specified series from TheTVDB
* A demo is available at http://dogancelik.com/dizi/
* How to use: Request this page bolum.php?d=NAME_OF_THE_SERIES&s=SEASON_NUMBER
*/
//error_reporting(E_ALL);
@dogancelik
dogancelik / convert.py
Created May 23, 2012 21:11
(Python) Convert ShiftJIS to UTF-8
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Convert ShiftJIS to UTF-8
# Usage: cat ShiftJIS.txt | ./convert.py > UTF8.txt
# Alternative method: cat ShiftJIS.txt | iconv -f shift_jis -t utf8 > UTF8.txt
import sys
import codecs
@dogancelik
dogancelik / Open In Browser.py
Last active October 5, 2015 13:57
(Sublime Text) How to view/open file in browser in Sublime Text 2?
import sublime, sublime_plugin
import webbrowser
class OpenInBrowser(sublime_plugin.TextCommand):
def run(self, edit):
webbrowser.open(self.view.file_name())
@dogancelik
dogancelik / set-keyboard.ps1
Last active February 15, 2022 12:23
(PowerShell) Set Language List to Turkish and Japanese / Set Keyboard Layout to US (Turkish Q)
# Credit: http://drizin.io/Change-Keyboard-Input-Languages-with-Powershell/
$currentLangAndKeyboard = (Get-WinUserLanguageList).InputMethodTips
if ($currentLangAndKeyboard -eq "0409:00000409")
{
$langList = New-WinUserLanguageList en-US
$langList[0].InputMethodTips.Clear()
$langList[0].InputMethodTips.Add('0409:0000041F')
Set-WinUserLanguageList $langList
@dogancelik
dogancelik / gist:5521559
Last active December 17, 2015 00:29
(Python) timeit for "check object if it's a list"
import timeit
# Tested on Python 2.7.5 (64-bit)
t = timeit.Timer(stmt="isinstance(['a', 1], types.ListType)", setup="import types")
print t.timeit() # 0.310844602274
t = timeit.Timer(stmt="isinstance(['a', 1], list)")
print t.timeit() # 0.313751077743
@dogancelik
dogancelik / gist:5541173
Last active December 17, 2015 03:09
(Python) timeit for zeroing time attributes in a datetime object
import timeit
t = timeit.Timer(stmt="datetime.datetime(*datetime.datetime.now().date().timetuple()[:6])", setup="import datetime")
print t.timeit() # 4.80428367916
t = timeit.Timer(stmt="datetime.datetime.combine(datetime.datetime.now().date(), datetime.time(0, 0, 0))", setup="import datetime")
print t.timeit() # 3.23761676673
@dogancelik
dogancelik / gist:5650542
Last active December 17, 2015 18:08
(Python) timeit for getting filename without extension
import timeit
t = timeit.Timer(stmt="splitext(__file__)[0]", setup="from os.path import splitext")
print t.timeit() # 2.1748800403
t = timeit.Timer(stmt="__file__[:-3]")
print t.timeit() # 0.110901126177
t = timeit.Timer(stmt='__file__[:__file__.rindex(".")]')
print t.timeit() # 0.387404180721
@dogancelik
dogancelik / bleach_parse.coffee
Created August 7, 2013 12:36
(PhantomJS) Parse Bleach episodes in Wikipedia
page = require('webpage').create()
fs = require 'fs'
system = require 'system'
page.onConsoleMessage = (msg) -> console.log(msg)
page.open "http://en.wikipedia.org/wiki/Bleach_episodes", (status) ->
csv = page.evaluate ->
formatDate = (date) ->
date.getFullYear() + "-" + ((if date.getMonth() < 9 then "0" else "")) + (date.getMonth() + 1) + "-" + ((if date.getDate() < 10 then "0" else "")) + date.getDate()
@dogancelik
dogancelik / gist:7173121
Last active February 24, 2018 19:30
(HexChat) Foobar2000 Now Playing Plugin (Windows only) (Broken)
# Requires http://sourceforge.net/projects/pywin32/
__module_name__ = 'Foobar2000 Now Playing'
__module_version__ = '0.1'
__module_description__ = 'Prints what is playing from foobar2000'
import xchat
import win32gui
import re