Skip to content

Instantly share code, notes, and snippets.

View halilim's full-sized avatar

Halil Özgür halilim

View GitHub Profile
@halilim
halilim / git diff without newline changes
Last active December 10, 2015 03:18
Since `git diff --ignore-space-at-eol --name-only` doesn't work (http://git.661346.n2.nabble.com/git-diff-ignore-space-at-eol-issue-td7573503.html) this is the command that gets closest to getting only the file names...
git diff --ignore-space-at-eol --stat
@halilim
halilim / git-discard-newline-only-changes.sh
Created March 12, 2013 16:19
Discards files with only newline changes. Main idea from http://stackoverflow.com/questions/12092714/how-to-git-reset-hard-everything-but-4-files NOTE: Test it first without checking out actually!!!
# Windows: doesn't work in Git Bash, use Cygwin (with cd "D:\etc..." first)
for file in $(git diff --ignore-space-at-eol --stat=1000,1000|cut -d' ' -f2|head -n -1); do git add $file; done && git checkout .
@halilim
halilim / phar.bat
Created March 23, 2013 10:43
Windows phar shortcut
@REM 1) Put this file in your PHP bin folder (e.g. ...\Program Files\PHP)
@REM 2) Put .phar files in a subfolder phar\
@REM 3) Call .phar's like: phar php-cs-fixer --etc --etc
@REM Currently doesn't support more than 8 arguments to the phar, since I couldn't find an easy way to have shift(%*)
@php %~dp0phar\%1.phar %2 %3 %4 %5 %6 %7 %8 %9
@halilim
halilim / gae_serve_php.bat
Created June 18, 2013 06:55
Google App Engine for PHP Local Dev Server Shortcut For Windows
REM Python Install Path (e.g. C:\Python2.7) should be in your %PATH%, or you should provide a full path instead of "python"
REM Put this in some folder that is in your %PATH% as well
REM Run this as "gae_serve_php path\to\project", if already in the project dir "gae_serve_php ."
python "<PATH TO GAE PHP SDK>\google_appengine\dev_appserver.py" --php_executable_path="<PATH TO PHP 5.4>\php-cgi.exe" "%1"
@halilim
halilim / optionTextPluckJoin.js
Created July 26, 2013 08:47
Pluck texts of all options of a select and join them with \n. Useful for pasting into Navicat.
jQuery.makeArray($("<SELECTOR>").find("option").map(function() { return $(this).text(); })).join("\n");
<?php
// http://googlewebmastercentral.blogspot.com/2011/01/how-to-deal-with-planned-site-downtime.html
header('HTTP/1.1 503 Service Temporarily Unavailable');
?>
<!doctype html>
<html itemscope itemtype="http://schema.org/WebPage">
<head>
<meta charset="utf-8">
<title>Company Name</title>
</head>
@halilim
halilim / bitki_puan_sira.sql
Created August 4, 2013 13:33
Bitki puan sırası
SELECT
t.bid, t.badi, t.averaj, t.sira
FROM (
SELECT b.bid, b.badi, p.averaj, @sira := @sira + 1 AS sira
FROM bitki b
JOIN (SELECT @sira := 0) r
INNER JOIN (SELECT bid,AVG(puan) averaj FROM puanlar GROUP BY bid) p ON p.bid=b.bid
ORDER BY p.averaj DESC
) t
WHERE t.bid = 3;
@halilim
halilim / thunderbird_with_smtp__log.bat
Created August 6, 2013 08:51
Start Thunderbird with logging enabled - Windows
set NSPR_LOG_MODULES=smtp:5
set NSPR_LOG_FILE=D:\Users\halil\Desktop\smtp.log
"%ProgramFiles(x86)%\Mozilla Thunderbird\thunderbird.exe"
@halilim
halilim / switch.bat
Created August 25, 2013 16:41
Simple Apache/PHP version switcher. Assumes there are folders like "php5.4", "Apache2.4Win64VC11", "php5.5VC11x64ts" etc with php and Apache unzipped. Usage: switch 2.4 5.5
:: Simple Apache/PHP version switcher. Assumes there are folders like "php5.4",
:: "Apache2.4Win64VC11", "php5.5VC11x64ts" etc with php and Apache unzipped.
:: Usage: switch 2.4 5.5
@echo off
:: Get Apache service version, e.g. 2.2/2.4
set ApacheName=%1
set ApacheServiceVersion=%ApacheName:~0,3%
@halilim
halilim / DNS-Switcher.jse
Created September 1, 2013 14:11
Windows DNS Switcher - Switch your DNS resolvers for all network interfaces in Windows from command line.
/**
* Windows DNS Switcher - Don't wear out your mouse trying to change your DNS server adresses.
* @author Halil Ozgur
* @license GPL Licence
*/
var dnsler = [
["Empty (DHCP-Auto)", []],
["OpenDNS", ["208.67.222.222", "208.67.220.220"]],
["Google DNS", ["8.8.8.8", "8.8.4.4"]],