Skip to content

Instantly share code, notes, and snippets.

View korayguclu's full-sized avatar

Koray Güclü korayguclu

View GitHub Profile
@korayguclu
korayguclu / gist:5508795
Created May 3, 2013 12:20
pars Character Encoding from contentType
// Taken from http://svn.apache.org/repos/asf/nutch/trunk/src/java/org/apache/nutch/util/EncodingDetector.java
/**
* Parse the character encoding from the specified content type header.
* If the content type is null, or there is no explicit character encoding,
* <code>null</code> is returned.
* <br />
* This method was copied from org.apache.catalina.util.RequestUtil,
* which is licensed under the Apache License, Version 2.0 (the "License").
*
* @param contentType a content type header
@korayguclu
korayguclu / gist:5508961
Created May 3, 2013 12:55
Convert byte to Hex to analyse Encoding problems
public String byteToHex(final byte b) {
// Returns hex String representation of byte b
char hexDigit[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] };
return new String(array);
}
@korayguclu
korayguclu / clone.sh
Last active December 28, 2015 04:09
clone a website with wget
wget --wait=20 --limit-rate=20K -r -p -U Mozilla http://guides.rubyonrails.org/getting_started.html
@korayguclu
korayguclu / gist:7441022
Created November 13, 2013 00:00
reseting mysql password
sudo /etc/init.d/mysql stop
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
mysql -u root
FLUSH PRIVILEGES;
SET PASSWORD FOR root@'localhost' = PASSWORD('password');
#If you have a mysql root account that can connect from everywhere, you should also do:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
@korayguclu
korayguclu / sphinx-install.sh
Created November 13, 2013 00:02
install sphinxsearch
wget http://sphinxsearch.com/files/sphinxsearch_2.0.5-release-0ubuntu11~precise2_amd64.deb
apt-get install libpq5
# install deb package
dpkg -i sphinxsearch_2.0.5-release-0ubuntu11~precise2_amd64.deb
# this will install following commands
# /usr/bin/searchd
# /usr/bin/indexer
# /usr/bin/search
@korayguclu
korayguclu / default.conf
Created November 15, 2013 13:31
nginx configuration for slimframework
server {
listen 80 default ; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
charset utf-8;
#root /usr/share/nginx/www;
#root /var/www/evevgez.com/html;
root /vagrant/html/evevgez-search ;
# Make site accessible from http://localhost/
server_name _;
client_max_body_size 20M;
@korayguclu
korayguclu / gist:9955ac7988a406279fec
Created May 9, 2014 16:26
Google Maps get viewport latitude and longitude
/*
Map.getBounds() gives you the lat/lng bounds of the current viewport. You can then use
LatLngBounds.getNorthEast() and LatLngBounds.getSouthWest() to get north-east (top right)
and south-west (bottom-left) coordinates as LatLng. More specifically:
ref: http://stackoverflow.com/questions/14285963/google-maps-get-viewport-latitude-and-longitude
*/
vagrant box add base-jruby http://files.vagrantup.com/lucid64.box
cd <project directory>
vagrant init base-jruby
vagrant plugin install vagrant-vbguest
vagrant up
vagrant ssh
sudo apt-get update
@korayguclu
korayguclu / gist:88ef327efc1b7f17ce39
Created May 12, 2014 16:54
install puppet to your server
wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
sudo dpkg -i puppetlabs-release-precise.deb
sudo apt-get update
sudo apt-get -y install puppet
@korayguclu
korayguclu / gist:f67449237da27711a9ec
Created May 15, 2014 09:04
install jruby into ubuntu 12.04
\curl -sSL https://get.rvm.io | bash
source /home/vagrant/.rvm/scripts/rvm
rvm install jruby
gim install rails