Skip to content

Instantly share code, notes, and snippets.

View halilim's full-sized avatar

Halil Özgür halilim

View GitHub Profile
@halilim
halilim / mass_convert_encoding.php
Created September 1, 2013 16:01
Mass convert encodings of files with selected extensions in a folder recursively.
#!/usr/bin/php
<?php
if (count($argv) < 6) {
echo '
Usage :
> php ' . $_SERVER['SCRIPT_FILENAME'] . '
source_folder
destination_folder
source_charset
@halilim
halilim / mysql_mass_change_charset.php
Last active December 22, 2015 02:49
Mass MySQL database character set changer
<html>
<head>
<title>Mass MySQL database character set changer</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<pre><?php
$db_host = 'localhost';
$db_user = 'root';
@halilim
halilim / bozuk_turkce_karakter_duzelt.php
Created September 1, 2013 18:32
Bozuk Türkçe karakter düzelt - Fix corrupt Turkish characters
<?php
function array_make_first(&$array, $element) {
if (($ndx = array_search($element, $array)) !== false) {
unset($array[$ndx]);
array_unshift($array, $element);
}
}
$encler = mb_list_encodings();
@halilim
halilim / gezgin.php
Last active December 22, 2015 02:49
A PHP file and db explorer (shell?) experiment from the past
<?php //İ
define('_K','b7f3l0h');
define('U_IPC',true);
define('U_U','test');
define('U_P','test');
define('U_UA',$_SERVER['HTTP_USER_AGENT']);
define('U_IP',$_SERVER['REMOTE_ADDR']);
// todo: secure this (i.e. include in the logged in part)
if (isset($_GET['dl']))
@halilim
halilim / gzipper.php
Created September 1, 2013 19:09
GZip a File
<?php
if (!empty($_POST) && isset($_FILES['file'])
&& $_FILES['file']['error'] == UPLOAD_ERR_OK
) {
header(
'Content-Disposition: attachment; filename="'
. $_FILES['file']['name'] . '.gz";'
);
echo gzencode(file_get_contents($_FILES['file']['tmp_name']));
exit;
@halilim
halilim / delete_iconcache.bat
Created September 3, 2013 15:11
Purge (Delete) Windows icon cache
taskkill /F /IM explorer.exe
cd /d %userprofile%\AppData\Local
attrib –h IconCache.db
del IconCache.db
start explorer
@halilim
halilim / truecrypt_skype.bat
Created September 3, 2013 15:59
Helps securing Skype profile by storing it in a TrueCrypt drive
@echo off
REM Helps securing Skype profile by storing it in a TrueCrypt drive
REM 1. Create the container if you don't have it
REM 2. Disable auto starting of Skype on Windows Start
REM 3. Log out and completely exit Skype
REM 4. Move %APPDATA%\Skype into the container, e.g. K:\AppData\Skype
REM 5. mklink /D "%APPDATA%\Skype" "K:\AppData\Skype"
REM 6. Add a shortcut like `C:\Code\truecrypt_skype.bat D:\test\example.tc`
REM to "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup"
@halilim
halilim / Array_insert.php
Last active December 22, 2015 23:39
A PHP function that can insert at both integer and string positions
<?php
/**
* A function that can insert at both integer and string positions
*
* @param array $array
* @param int|string $position
* @param mixed $insert
*/
function array_insert(&$array, $position, $insert)
@halilim
halilim / Link_solr_conf.sh
Last active December 26, 2015 05:29
Symlinks data-config.xml, schema.xml and solrconfig.xml, copies db-connection.xml. This is for projects where Solr configs reside inside the main repo and the db parameters are specified using an external file.
@halilim
halilim / simple git deploy
Created November 29, 2013 12:02
A very simple git deploy method. `git init` anywhere (e.g. /home/user/src) and add this to `.git/hooks/post-receive`. Now when you do `git push production master` (assuming the remote for server is "production"), your project will be deployed. Replace `/home/user/public_html` with the working directory (e.g. the web/project root). Files tracked …
GIT_WORK_TREE=/home/user/public_html git checkout -f