Install LaTeX on Mac with Brew

latexThis post will show you how to install LaTeX easily on a Mac with the package manager Homebrew.

You can directly install MacTex or BasicTex from https://tug.org/mactex/ and follow the instructions from 3 to 4. But I prefer brew for its ease.

1. First you should install Homebrew;
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

You may look at brew.sh for newer or additional installation methods. After you have installed brew you can easily search for packages with

brew search wget

or install found packages by

brew install wget

You may use brew for installing various packages, command line tools, applications etc.

2. There is a small twist while installing MacTex or BasicTex packages. Because they are supplied at the Homebrew Cask repository. Cask is a community contributed repository for large binaries and applications. So you should add cask command before installing MacTex or BasicTex.

brew cask install basictex
to install basictex or
brew cask install mactex
for mactex.

MaxTex is more than a GB and BasicTex is around 90MBs. There are many packages that you will never use in MacTex thus I prefer the BasicTex.

3. Now you will need a simple text editor to write LaTeX. Then simply use the command line to convert your raw latex code to pdf. You may also use a latex editor like TexMaker if you prefer a GUI. MacTex readily comes with some tex editors.

4. As BasicTex is very lightweight it is missing some essential packages. If you get errors like “multirow.sty not found” while compiling tex then you should install the missing modules. The package tlmgr is used to install the missing modules.

For example;

sudo tlmgr install multirow

tlmgr comes with BasicTex.

I have used the following resources to summarize the installation process and install latex myself on El Capitan.

  1. http://www.pydanny.com/setting-up-latex-on-mac-os-x.html
  2. http://www.bilalakil.me/getting-started-and-productive-with-latex-basictex-on-os-x-terminal/
  3. http://tex.stackexchange.com/questions/974/why-is-the-mactex-distribution-so-large-is-there-anything-smaller-for-os-x

Nerve: Journey of the Hero and a Short Cinematographic Review

The movie Nerve portrays a dystopian world of technology. It may be considered as science fiction but it doesnt tell about a future, impossible or a parallel world. The movie exactly tells the story of how the exact current technologies can result in evil.

The storyline of the movie is a good fit for Joseph Campbell’s storyline of hero’s journey. Protagonist of the movie Vee has a dull life and her family is not wealthy. Her dreams are far away from her achievements in her ordinary world.

One of her best friends Sydney who is more joyous and courageous has found out a new online game Nerve. She achieves some real world tasks defined by an online realtime audience and earns money and gain online reputation as she succeeds. At first Vee refuses to join the game just watches Sydney.

One day Sydney by the courage that she gained within the game she messes with Vee’s platonic love which throws Eve off balance. Vee becomes eager to try new things and take more risks. In this bit, with her incentive words Sydney is like a role model and a mentor for Vee.

When Vee tries the Nerve just for once she meets with another player named Ian. Even though Vee’s friend Tommy try to stop her Vee falls in love with Ian and continues to play the game with him. She crosses the threshold and starts her journey with no turning back.

In this special world of the game she becomes very successful and goes up in the leaderboard. This results with her best friend Sydney to become jealous of her. In the course of events Vee gains enemies and allies.

The course of the events bring Vee and Sydney face to face and the requirements of the game deadly. Step by step the tension built and conflicts started to arise. Vee accepts one last requirement to portray how things become silly and out of control and then quits the game.

But the game doesn’t quit Vee and take her as a slave. Vee wakes up in a container depot in a great crisis finds herself beeing threatened where the container symbolizes the Dragon’s Den in the Hero’s journey.

So with Ian and her friends they make a plan to shut down the game. She takes the law in her hand and returns back the game. Their plan seems to go bad but Vee resurrects and free everyone from the Nerve.

If we put aside how didactic the film becomes at the end it portrays really well the consequences of anonymity online. An anonymous crowd is defiant and more dangerous than a single anonymous person.

They don’t accept any responsibility of any crime however the crowd decides on the course of the game. This decision process is called to be democratic but results in fatal actions. So the film criticizes whether the decision of majority is always true. When a watchers true identity is exposed, the watcher becomes a minority and hypocrisy arises.

Anonymity is symbolized with props like scarves and Guy Fawkes masks hiding people’s faces. The decision process being virtual with a mobile app shows also how democracy is just an illusion. In the film democracy is literally a game.

The film has a fast pace supported by reckless moves and exciting actions. The sound and music is hand in hand with this fast pace. Scenes are mostly dark, takes place at night but vivid in color both symbolizing danger and virtuality. Scenes are in fact like from a high quality video game. Overlays of buttons, text messages and social media notifications fill the screen for most of the time.

Nerve doesn’t portray a totally new concept but rather in a different way. To make the film popular among youth it feels like that the story is specially constructed for the purpose. However it is consistent with the age range of the characters that may participate in such a game. So for an audience of youth this may be just an entertaining film but an attentive audience may find more.

Android Keystore Alias ve Şifremi Unuttum

Şifrelerimi düzenli bir şekilde saklarım ama acil kodlu işlerde yeni açtığım hesapları, kullanıcı adlarını ve şifreleri sonra kayıt altına almak üzere bir kenara not alırım. İşte o notları düzenlemezsem…

Eğer sizde keystore alias ve şifrenizi unutursanız ikisinin kombinasyonuyla denemeler yapmak yerine vaktinizi sadece olası şifreleri denemek için kullanabilirsiniz.

Aşağıdaki komut keystore içerisine kayıtlı aliasların hepsini listeleyecektir. Tabi ki doğru şifreyi girmeyi başarırsanız.

keytool -list -keystore /dizin/dizin/ornek.jks

Not: Ben başardım 🙂

MySQL Decimal, Double, Float Rounding Problem

When importing CSV with decimal values to MySQL, the numbers are rounded. I have searched on google but didn’t find a solution so I have come up with my own.

In CSV file decimal part is seperated with a comma “,” , however MySQL accepts a dot “.”.
So just replace commas with dots in your CSV file. That easy 😉


sed -i 's/,/./g' your_file.csv

Single S3 Bucket Policy

It requires two different policies to be assigned to the group or user. With this policy setup the user can’t list other buckets.

1st Policy


{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "XXX",
"Effect": "Allow",
"Action": [
"s3:DeleteObject",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::<bucketname>"
]
}
]
}

2nd Policy


{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "XXX",
"Effect": "Allow",
"Action": [
"s3:DeleteObject",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::<bucketname>/*"
]
}
]
}

The only difference between these two policies are the ARN (Resource) Part. The second has the * wildcard.
If you just use the 1st policy then the user can not make any changes inside the bucket but can list the files. If you just use the 2nd policy the user can not login to the bucket at all. That’s why both are required.

If you have discovered an easier way please share at the comments.

Update:

Similar solution at Blog AWS.


{
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket" ],
"Resource": [ "arn:aws:s3:::test"]
},
{
"Effect": "Allow",
"Action": [ "s3:PutObject", "s3:GetObject", "s3:DeleteObject"],
"Resource": [ "arn:aws:s3:::test/*"]
}
]
}

MySQL CSV Import

Üzerinde çeşitli analizler yapabilmek için son 10 yıllık EUR/USD paritesinin 1 dakikalık verilerini MySQL veritabanına aktarmam gerekti. Siz de veritabanı düzenine sahip herhangi bir CSV dosyasını komut satırını kullanarak aşağıdaki gibi içe aktarabilirsinz.


mysql -u username -p dbname --local-infile


load data local infile 'eurusd.csv'
into table eurusd fields terminated by ','
enclosed by '"' lines terminated by '\n'
(id, date, time, value)

Elinizdeki CSV formatına göre “fields terminated by” ve “enclosed by” parametrelerini değiştirmeyi unutmayın. “terminated by” hücreleri hangi karakterin ayırdığını, “enclosed by” ise hücrelerin hangi karakter ile sarıldığını ifade ediyor. Örnek olarak;


terminated by ',' ve
enclosed by '"'
ise
"Hucre 1","Hucre 2"

“lines terminated by” ifadesi de satır sonunu ifade ediyor. Windows veya Mac bilgisyarda hazırlanan CSV lerin farklı satır bitişleri olabilir.

Mysql Veri Tiplerinde Length Parametresi

MySql veri tipleri hakkındaki bir yanlışımı az önce öğrendim ve bir çok kişinin de bu konuyu yanlış bildiğini düşünüyorum.

Bildiğiniz gibi char, varchar, tinyint, int, bigint gibi veri tiplerinin hepsi length (size veya uzunluk olarak da geçer) parametresi alır. char ve varchar tipleri için bu değeri tanımladığınız zaman, tanımlanan değer kadar karakter saklanır. Örnek olarak varchar(3) olarak tanımlarsak saklanan değerler aşağıdaki gibi olabilir;

  • abc
  • tef
  • ağa

Doğal olarak int(3) değeri için de saklanacak değerin -999 ve 999 arasında olabileceği aklımıza geliyor. Halbuki int(3)’ün sakladığı değer (4 byte) değişmiyor. Değişen tek şey verinin gösterim uzunluğu oluyor. Yani kayıt ettiğiniz int değeri veritabanında yine 4 byte kaplarken yalnızca sayının 3 hanesi gösteriliyor.

Peki o zaman uzunluk tanımlamanın ne faydası var. Eğer uzun tanımlarsanız; sayısal tipler için tanımlanan uzunluk değeri, zerofill (sıfırla doldur) özelliği ile birlikte kullanıldığında aşağıdaki gibi getirilir. (Aşağıdaki örnek int(4) için verilmiştir.)

  • 0005
  • 0004
  • 0011

Kaynaklar:
http://dev.mysql.com/doc/refman/5.0/en/numeric-type-attributes.html
http://dev.mysql.com/doc/refman/5.0/en/integer-types.html

Komut Satırı'ndan Youtube'a Video Yükleme

Youtube Upload isimli python scriptiyle komut satırından youtube hesabınıza video upload edebilirsiniz.

Google Code Sayfası: http://code.google.com/p/youtube-upload/

$ youtube-upload --email=kullaniciadi@gmail.com --password=sifre --title="Başlık" --description="Açıklama" --category=Kategori --keywords="anahtar, kelimeler" upload-edilecek-video.mpeg

“–category” parametresine mutlaka Youtube’un tanımladığı geçerli parametrelerden birini vermelisiniz.
Geçerli Parametreler aşağıdaki gibi;

  • Autos
  • Comedy
  • Education
  • Entertainment
  • Film
  • Gaming
  • Howto
  • Music
  • News
  • Nonprofits
  • People
  • Pets
  • Science
  • Sports
  • Travel