psycho-intelligent junior web developer. thinks, eats, shits, fucks, and rarely loves.
www.rahmetli.info
To upload any file to the F folder, the students of Koç University are required to connect NetStorage by using “File Access” section under My.KU as CIT informs. For other purposes such as downloading files, FileZilla is given as an option. This is unnecessary…
NetStorage is built on an extension of HTTP which is called WebDav. Most of the FTP clients are able to create WebDav connections but FileZilla.
Cyberduck is a “FTP, SFTP, WebDAV & cloud storage browser for Mac & Windows” that you can use to connect NetStorage and upload your files and homeworks. For those whom would like to know the steps:
1) Click on “Open Connection” and select WebDAV (HTTP/SSL) as the preferred option:
2) Fill in the settings:
Server: netstorage.ku.edu.tr , Port: 443 (Default)
Username: school username (ex: esaral)
Password: school password (ex: 123456abc)
Path: /oneNet/NetStorage (THIS IS REQUIRED! But you can add any desired path after the root)
Example Path: /oneNet/NetStorage/DriveF@VOL/COURSES/UGRADS (to go directly under UGRADS folder)
ADDITIONAL INFO:
- You don’t have to use Cyberduck, this is only one of the most popular ones. There are bunch of FTP clients you can rely on. BitKinex (Windows-only) is also one of them. On the other hand, you can try “mapping network drive” to WebDAV in Windows 7 (and Vista) by reading this article.
- If you are a Mac user, you should be probably using Transmit because it’s magnificent, but you may use “Go -> Connect to Server” in Finder as well.
I’m experienced at multi-thread programming in Java but never used this method in C. One of our homeworks required a session management for a program that ends the execution if the user stays inactive for 60 seconds; therefore using a thread to handle session expiration sounds very useful. Here’s a simple example of implementing this method which I wrote:
#include <stdio.h> #include <unistd.h> #include <time.h> #include <pthread.h> // necessary #include <stdlib.h> // Session limit in seconds #define SESSION_TIME 60 // Global last interaction variable time_t lastInteraction; // Thread function that will control session time void * session(void * arg) { // Session will constantly check if the session is expired or not while(1) { // In each loop, get current time time_t c; time(&c); // Then compare it with the lastInteraction time if(c - lastInteraction >= SESSION_TIME) { printf("Session expired\n"); exit(0); } } } int main(int argc, char const *argv[]) { // Set the initial interaction time time(&lastInteraction); // Create session /* * Note: if pthread_create executes successfuly, tid gets the return id of session. * First NULL indicates we will use default attributes for our thread * session is the name of the method which will handle thread's execution * last NULL is the argument will be used inside session but I preferred using it globally */ pthread_t tid; pthread_create(&tid, NULL, session, NULL); // Create input string char input[30]; // Program starts while(1) { // Ask user for inputs with scanf (or fgets depending on your program) // Assume that user waits and does not enter any thing for 60 seconds, // during this time thread gets executed and checks whether the limit is reached or not printf("Enter something: "); input[0] = '\0'; // optional: empty the string scanf("%s", input); // Update the last activation time after user gives an input time(&lastInteraction); } return 0; }
There is no application that can truly inform you about bus hours in Istanbul. Therefore I thought I should build mine. I simply get the data from IETT‘s content (I wish they had API) by using regular expression methods. This is sure a web application and I used iWebKit for the interface and PHP for the background.
The application’s interface is currently in Turkish. Simply you write the code of the bus line into the box and optionally select arrival/departure options. Then the application gets the list of whole bus stops and timetables for you. The information is always up to date and it’s always free.
You can try the application here: http://www.rahmetli.info/iett/
GPA Recorder is a simple GPA calculator with additional features such as keeping records of the courses. You can calculate your GPA of a selected semester along with your total GPA and see the change on action.
+ Why people would need this application?
- I’m not sure but I made this because I wanted to see my final GPA with expected grades.
Here is the download link: http://www.rahmetli.info/files/GPA%20Recorder.jar
ATTENTION:
Please try to keep the application in a folder because it creates a hidden database file in its same directory. If you try to move the application, its database remains in old directory as a folder named “.gpa_data”.
Current features:
- GPA is calculated over 4.00
- Maximum credit hours value is 6
- Values of an added course can be replaced by clicking on its table values
- Ability to sort each table column
- Cross platform application which requires Java 1.6+
- No limit at adding courses
- No need of the internet connection (except sending suggestions)
- Enable/disable course in the table (added in v1.1)
In future releases:
- Online access to the course database with user registration will be added
- Auto-complete in course name will be added
- Undo the last action will be added
- Multiple selection in the course table will be added
NOTE:
The main purpose of creating this application is experiencing Java RDBMS, SQL (sqlite, mysql), Java Applets and JSP.
You can see the details of RSA algorithm here.
Shortly: For a given prime number n, we must take its prime factorization to find p and q that n = p*q. Then we need to find the exponent e which is between 1 and (p-1)*(q-1), and the number d which is the modular inverse of e in modulo (p-1)*(q-1) so that we will be using extended Euclidian algorithm.
Algorithms which will be used:
- Prime validation:
boolean isPrime(n: Integer)
- Finding factors of a prime number:
ArrayList<Integer> findFactors(n: Integer)
- Finding greatest common divisor:
int gcd(num1: Integer, num2: Integer)
- Getting p and q from n:
int[] getFactorizationPair(n: Integer)
- Calculating modular exponentiation:
int modularExpo(b: Integer, e: Integer, m: Integer)
- Calculating extended Euclidian:
int[] extendedEuclidian(f: Integer, a: Integer)
- Calculating modular inverse:
int modularInverse(n: Integer, m: Integer)
- Finding e (exponent):
int findExponent(p: Integer, q: Integer)
- Decryption:
ArrayList<Integer> decrypt(blocks: ArrayList<Integer>, d: Integer, m: Integer)
Prime validation:
public boolean isPrime(int n){ for(int i = 2; i <= input/2; i++){ if(input % i == 0){ return false; } } return true; }
Finding greatest common divisor:
public int gcd(int num1, int num2){ int x; int y; while(num1 % num2 != 0){ x = num2; y = num1%num2; num1 = x; num2 = y; } return num2; }
Finding factors of a prime number:
public ArrayList findFactors(int n){ ArrayList factors = new ArrayList(); int temp = input; for(int i = 2 ; i < input; i++){ // try prime numbers to divide input, if it divides add it to factors if(isPrime(i)){ while(temp % i == 0){ factors.add(i); temp = temp / i; } } } return factors; }
Getting p and q from n:
public int[] getFactorizationPair(int n){ int [] pair = new int[2]; ArrayList f = findFactors(n); if(f != null){ pair[0] = 1; for(int i = 0; i < f.size() ; i++){ if(f.get(i) == f.get(0)){ pair[0] = pair[0] * f.get(i); } } pair[1] = n / pair[0]; } // p = pair[0], q = pair[1] return pair; }
Calculating modular exponentiation:
public static int modularExpo(int b, int e, int m){ String eBinary = Integer.toBinaryString(e); int x = 1; int power = b % m; // because of binary representation, loop goes in opposite direction for(int i = eBinary.length() -1 ; i >= 0 ; i--){ if(Character.digit(eBinary.charAt(i), 10) == 1 ){ x = (x * power) % m; } power = (power*power) % m; } return x; }
Calculating extended Euclidian:
public static int[] extendedEuclidian(int f, int a){ int s0 = 1; int s1 = 0; int t0 = 0; int t1 = 1; int dividend = f; int divisor = a; int r = dividend % divisor; // remainder int q = dividend / divisor; // quotient dividend = divisor; divisor = r; while(r != 0){ int stemp = s0 - (q * s1); s0 = s1; s1 = stemp; int ttemp = t0 - (q * t1); t0 = t1; t1 = ttemp; r = dividend % divisor; q = dividend / divisor; dividend = divisor; divisor = r; } int array[] = {s1,t1}; return array; }
Calculating modular inverse:
public static int modularInverse(int n, int m){ // in the equation of f*s + a*t of ExtendedEuclidian, t represents the inverse of a in modulo f int pair[] = extendedEuclidian(m, n); return pair[1]; }
Finding e (exponent):
public static int findExponent(int p, int q){ // if p is smaller than q, swap them if(p < q){ int t = p; p = q; q = t; } for(int i = (q - 1) ; i>=2; i--){ if(gcd(i, (p-1) * (q-1) ) == 1){ return i; } } // in case of the condition does not hold return -1; }
Decryption:
public static ArrayList<Integer> decrypt(ArrayList<Integer> block, int d, int m){ ArrayList<Integer> newBlock = new ArrayList(); for(Integer i : block){ i = modularExpo(i, d, m); newBlock.add(i); // i refers to each decrypted message: c^d = i (mod m) } return newBlock; }
Source(s):
“Discrete Mathematics and Its Applications” 6th Edition by Kenneth H. Rosen from McGraw-Hill;
Extended Euclidian algorithm in page 246,
Modular Exponentiation algoritm in page 226.
If you are a Mac user, probably you don’t want to see any trademark of Microsoft on your computer. Therefore you may want to open or edit your .doc/.docx files in Pages. By default, you are able to view those files in Pages. The only thing you have to do is changing default application for those extensions. Just click right to the file and select “Get Info”:
Here is the tricky part. Some good people at Apple decided to build Pages as a viewer of Word documents. It may be because of market strategies. Anyway, you can only open the document and view it, you can’t directly change itself. To be able to edit your document when you are simultaneously viewing it, you have to change the configurations of Pages.
Go to your applications folder, click right to Pages and open “Show Content Packages” and later “Contents”. You will see a file named “Info.plist”. You have to edit this file manually and replace the attribute “Viewer” with “Editor” for the type of Word documents:
If you can’t edit “Info.plist” because of permission denial, you can try using Terminal. Type this line in your console and hit enter:
“sudo nano /Applications/Pages.app/Contents/Info.plist”
Last, change those lines from “Viewer” to “Editor”:
For a long time I haven’t gone for a vacation, and this was the first time visiting the south of Turkey especially with a bunch of friends in a car. My lieutenant cousin, his brother and two friends from the military academy, and me. As you can guess, our road trip was fun but also tiring. Thanks that I didn’t get my driver license yet, I was out of the drivers’ list, but I might call myself the guide because my iPhone knew the way all the time.
The route was starting from Ankara and ending in Bodrum, Muğla on 4th September, but I was in Trabzon (Northeast of Turkey) at this time. I flied over Ankara and joined the guys, and the trip started around 11 am. We didn’t know it was going to be too late in the end. We didn’t also know it would be too boring in the car because there was no cd player, and the music we had wasn’t enjoying us. I barely remember what we talked about until arriving Soke, Aydin. In this small town, there was a huge house of the family of my cousin’s friend (Mehmet Ali) in a village, and they nicely welcomed us. Even they gave gifts after a lovely dinner before we continue our way. At least we were full, and I can’t describe the happiness we had. I must say that I didn’t expect that hospitality, but even Mehmet’s father served us on the dinner table. I’m still very thankful for that night.
We arrived home at 1 am on 5th September. The summer house of my cousin was a total mess or garbage I must say, and he and his friends didn’t become uncomfortable as I did so I went to neighbors to ask for some cleaning materials. Surprising that neighbors invited us to drink some tea along with deserts. After a chit chat, we went back home and started cleaning. It was not going to finish if we didn’t just clean the surface. We slept without planning our holiday because we were exhausted.
First day was started at the beach of summer house. The water was not as we expected so we spent only a few house then we decided to visit Turkbuku (Golturkbuku). Because it was a bit late, the beach was almost empty so we couldn’t get fun as much as we did back at home. Therefore my friends went back to the city center, but I preferred staying to see one of my friends from Istanbul. After spending a few hours with her by eating and “more”, I joined the guys at Bodrum. I must say that the driver of minibus (dolmuş) was totally a local guy and his accent made me laugh a lot.
After one day with doing nothing and going out only at nights, we decided to spend our one of last days with a boat tour from 11 am to 6 pm. The coves of Bodrum were magnificent and I never experienced swimming that relaxing before. The water was so clear and still that I didn’t want to go out. Eventually the day was over and we got exhausted, again. Sleeping was a good choice.
On the last day we visited Ephesus, Izmir for a few hours and my friends continued without me because I gave a friend promise to meet her in Aydin. My mistake that I guessed Tire was one of Aydin’s towns. The fact that it was Izmir’s. So I went back from Tire to Selcuk but according to her she had other plans with her girlfriends. That made me so fucking angry because I covered almost 100 kms to see her and I had a flight to Istanbul one day later. Anyway, later I went back to Bodrum with bus and spent my last day alone. Staying in summer house by my own didn’t seem like a good idea so I looked for a friend and visited him. It was the first time I met him but he was so kind and had an intellectual mind that blew me out. Drinking white wine and watching an amazing view at midnight is the best memory I have from my trip. Ah, by the way his french bulldog was the cutest dog I’ve ever seen.
In the morning, he dropped me to bus terminal with his scooter after showing cute and lovely streets of Bodrum. I had 6 hours left until flight so I decided to visit a few museums in Bodrum. The first one was Mausoleum museum and the other one was Bodrum castle along with Museum of Underwater Archaeology. Then I tried delicious meals at different restaurants of Bodrum. I wish I hadn’t my backpack that heavy. Moreover I lost my last money and I was totally broke while I was going to the airport. I think the bad luck comes with good one because my parents were on their way to Istanbul on that time. I love happy endings.
I was trying to make my own simple to-do list and wanted to share it with you guys.
What it’s capable of:
- Authorization feature (admin).
- Add, edit, remove, move tasks.
- Done and undone (css representation).
First of all, you may want to take a look at demo, or download it.
PHP / HTML CODE:
<?php /* * Author: Emin Bugra Saral * Website: http://www.rahmetli.info * Purpose: How to make a to-do list with php * */ // SESSION session_start(); // DATABASE mysql_connect('localhost', 'user', 'password'); mysql_select_db('database'); // TASK FORM $form = '<form id="taskform" method="post">'; $form .= '<label for="task">Task</label>'; $form .= '<input id="task" type="text" name="task" />'; $form .= '<input name="add" type="submit" value="add" />'; $form .= '</form>'; // CREATE ID VARIABLE IF IT IS VALID if(isset($_GET['action']) && isset($_GET['id'])) { $q = mysql_query('SELECT * FROM todo WHERE id = "'.$_GET['id'].'"'); if(mysql_num_rows($q) != 0) $id = $_GET['id']; else $msg = "ERROR: id is not valid."; } // USE ID VARIABLE IF IT EXISTS if(isset($id)) { // ADMIN CHECK if(isset($_SESSION["user"])) { // MOVE IN THE LIST (YOU MAY PREFER USING SWITCH) if($_GET['action'] == 'down' || $_GET['action'] == 'up') { // QUERY TO CHANGE IDs OF TASKS if($_GET['action'] == 'down') $q = mysql_query('SELECT id FROM todo WHERE id >= "'.$id.'" LIMIT 2'); if($_GET['action'] == 'up') // CHANGE DIRECTION $q = mysql_query('SELECT id FROM todo WHERE id <= "'.$id.'" ORDER BY id DESC LIMIT 2'); // IF THERE ARE TWO ROWS, GO FOR IT if(mysql_num_rows($q) == 2) { $c = 1; while($row = mysql_fetch_assoc($q)) { // GET POSITIONS if($c++ == 1) $first = $row['id']; else $second = $row['id']; } // CHANGE POSITIONS (IDs) mysql_query('UPDATE todo SET id = "0" WHERE id ="'.$first.'"'); mysql_query('UPDATE todo SET id = "'.$first.'" WHERE id ="'.$second.'"'); mysql_query('UPDATE todo SET id = "'.$second.'" WHERE id ="0"'); header('Location: ./index.php'); } } // DONE - UNDONE elseif($_GET['action'] == 'mark') { $row = mysql_fetch_assoc($q); $mark = ($row['status'] + 1) % 2; $q = mysql_query('UPDATE todo SET status = "'.$mark.'" WHERE id = "'.$row['id'].'"'); if($q) header('Location: ./index.php'); else $msg = 'ERROR: database issue'; } // DELETE elseif($_GET['action'] == 'delete') { $row = mysql_fetch_assoc($q); mysql_query('DELETE FROM todo WHERE id = "'.$id.'"'); header('Location: ./index.php'); } // EDIT ALSO CHANGES FORM elseif($_GET['action'] == 'edit') { $row = mysql_fetch_assoc($q); $form = ''; $form .= '<form id="taskform" method="post">'; $form .= '<label for="task">Task</label>'; $form .= '<input id="task" type="text" name="task" value="'.htmlspecialchars(stripslashes($row['task'])).'" />'; $form .= '<input type="hidden" name="id" value="'.$row['id'].'" />'; $form .= '<input name="edit" type="submit" value="edit" />'; $form .= '</form>'; } } // ADMIN CHECK FAILS else { $msg = "ERROR: You don't have permission"; } } // ADD NEW TASK if(isset($_POST['add'])) { // REMOVE SPACES $task = trim($_POST['task']); // IF IT IS EMPTY if($task == '') { $msg = 'ERROR: fill in the blank'; } else { $q = mysql_query('INSERT INTO todo(task) VALUES ("'.mysql_real_escape_string($task).'")'); if($q) header('Location: ./index.php'); else $msg = 'ERROR: database issue'; } } // EDIT TASK if(isset($_POST['edit'])) { $task = trim($_POST['task']); $id = $_POST['id']; if($task == '') { $msg = 'ERROR: fill in the blank'; } else { $q = mysql_query('UPDATE todo SET task = "'.mysql_real_escape_string($task).'" WHERE id = "'.$id.'"'); header('Location: ./index.php'); } } // LOGIN USER if(isset($_POST['login'])) { $user = trim($_POST['username']); $pw = trim($_POST['password']); if($user == '' || $pw == '') { $msg = 'ERROR: fill in all blanks'; } else { $q = mysql_query('SELECT user FROM todo_admin WHERE user = "'.$user.'" AND password = "'.md5($pw).'"'); // IF USER EXISTS if(mysql_num_rows($q) != 0) { $row = mysql_fetch_assoc($q); $_SESSION["user"] = $row['user']; header('Location: ./index.php'); } else { $msg = 'ERROR: wrong information, try again.'; } } } // LOGOUT USER if(isset($_POST['logout'])) { // EMPTY SESSION $_SESSION = array(); header('Location: ./index.php'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>To-Do List</title> <style> body {font:14px Arial,Verdana,sans-serif; text-align:center;} a {color:#000;} a:hover{color:#666;} label {padding:5px;} #message {text-align:center;border:solid 5px #666;margin-top:10px;margin-bottom:10px; padding:10px;} #container {width:800px;margin:0 auto; text-align:left;} #taskform input[type=text] {width:400px;height:20px;font-size:14px;} #taskform input[type=submit] {margin-left:5px;width:50px;font-size:14px;} #list {border:none;padding:0;margin:0;} #list tbody tr:hover {background:#b2b2b2;} #list tr td {padding:5px;} #list tr td img {margin-right:10px;} .check {background: #F5A9A9;} </style> </head> <body> <div id="container"> <?php if(isset($msg)): ?> <div id="message"> <?php echo $msg; ?> </div> <?php endif; ?> <?php if(isset($_SESSION["user"])): ?> <form method="post"> <a href="./index.php" title="refresh">home</a> <input id="logout" name="logout" type="submit" value="logout" /> </form> <hr/> <?php echo $form; ?> <hr/> <?php else: ?> <form method="post"> <label for="username">username</label> <input id="username" type="text" name="username" value="admin" /> <label for="password">password</label> <input id="password" type="password" name="password" value="1234" /> <input name="login" type="submit" value="login" /> » admin 1234 </form> <hr/> <?php endif; $q = mysql_query('SELECT * FROM todo ORDER BY id ASC'); if(mysql_num_rows($q) != 0): ?> <table id="list"> <thead> <tr> <th valign = "top" width="20">#</th> <th valign = "top" width="400">Task</th> <th valign = "top" width="150">Date</th> <?php if(isset($_SESSION["user"])): ?> <th valign = "top" width="200">Action</th> <?php endif; ?> </tr> </thead> <tbody> <?php $out = ''; $i = 1; while($row = mysql_fetch_assoc($q)) { $status = $row['status']; $id = $row['id']; $out .= '<tr'.(($status==1)?' class="check"':'').'>'; $out .= '<td valign = "top">'.$i++.'</td>'; $out .= '<td valign = "top">'.htmlspecialchars(stripslashes($row['task'])).'</td>'; $out .= '<td valign = "top">'.$row['date'].'</td>'; if(isset($_SESSION["user"])) { $out .= '<td valign = "top">'; // done - undone $out .= '<a '.(($status==1)?'title="undone"':'title="done"').'href="./index.php?action=mark&id='.$id.'">'.(($status==1)?'<img src="./buttons/done.gif" alt="done" />':'<img src="./buttons/undone.gif" alt="undone" />').'</a>'; // edit $out .= '<a title="edit" href="./index.php?action=edit&id='.$id.'"><img src="./buttons/edit.gif" alt="edit" /></a>'; // delete $out .= '<a OnClick="return confirm(\'Are you sure?\');" title="delete" href="./index.php?action=delete&id='.$id.'"><img src="./buttons/delete.gif" alt="delete" /></a>'; // up- down $out .= '<a title="move up" href="./index.php?action=up&id='.$id.'"><img src="./buttons/up.gif" alt="move up" /></a><a title="move down" href="./index.php?action=down&id='.$id.'"><img src="./buttons/down.gif" alt="move down" /></a>'; $out .= '</td>'; } $out .= '</tr>'; } echo $out; ?> </tbody> </table> <?php else: ?> <p>There is nothing to do :(</p> <?php endif; ?> </div> </body> </html>
SQL CODE:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; CREATE TABLE `todo` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `task` longtext NOT NULL, `status` enum('0','1') NOT NULL DEFAULT '0', `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; CREATE TABLE `todo_admin` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `user` VARCHAR(40) CHARACTER SET utf8 NOT NULL, `password` VARCHAR(40) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
http://bar.rahmetli.info will redirect to http://www.rahmetli.info/index.php?username=bar
Here is the code to write into .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.rahmetli.info [NC]
RewriteCond %{HTTP_HOST} !^(www)\.rahmetli.info [NC]
RewriteRule (.*) index.php?username=%1
Fourth line will prevent ‘www’ to be redirected.
By using Custom Language Switcher of WPML, you can easily create your language list for your theme in WordPress. Sometimes ordering by types such as id, code and name can’t help you to get your default language to the top of list (array).
Making your default language’s position first in WPML’s language switcher requires an easy trick as shown below:
<?php // Get language array $list = icl_get_languages('skip_missing=1&orderby=id&order=asc'); // Getting default language to first position // Create a temporary array and hold its first position $temp[0] = ''; foreach($list as $l) { if($l['language_code'] == 'tr') // Turkish is default $temp[0] = $l; // assign default language to first position of temp array else array_push($temp, $l); // push other languages to temp } // change original with temp, then remove temp $list = $temp; unset($temp); // print links (you can use your own style) $print = '<ul class="myLanguageSwitcher">'."\n"; $c = count($list); // count languages for($i=0;$i<count($list);$i++){ // if the language is active, insert the class "active" $print .= '<li class="'.(($list[$i]['active']=='1')?'active':''); // if it's the last language in array, insert the class 'noBackground' if($i == $c - 1) $print .= ' noBackground'; // create link of language with native name $print .= '"><a title="'.$list[$i]['native_name'].'" href="'.$list[$i]['url'].'">'; $print .= $list[$i]['native_name']; $print .= '</a></li>'."\n"; } $print .= '</ul>' echo $print; ?>
Example Output:
While working with a huge database I encountered a memory size error that saying “Fatal error: Allowed memory size of x bytes exhausted“. I tried to chance memory size limit in php.ini file but it didn’t help at all. Using CodeIgniter might cause that the issue because I was using it’s own database functions to insert data. So, by also using CodeIgniter I found a simple solution to copy the table’s fields to another one: redirecting url by header function. This is very easy but I preferred to detail it. Lets go.
Note: Assuming that both tables are in the same database. You can also read this documentation to connect another database at the same time.
First I created a class to control (copy) table inserting:
<?php class copyTable extends MG_Controller { function index() { // this is main method, you don't need to use it } } ?>
Assuming that your url is http://www.rahmetli.info/codeigniter and you uploaded copyTable.php to that directory. You will write http://www.rahmetli.info/codeigniter/copyTable to run this class.
Anyway, I added a specific function to copy the table movies to the table films:
<?php class copyTable extends MG_Controller { function index() { } function moviesToFilms() { $url = 'http://www.rahmetli.info/codeigniter/copyTable/moviesToFilms'; $offset = $this->uri->segment(3); $limit = $this->uri->segment(4); $stop = $this->uri->segment(5); if($offset<$stop) { $q = $this->db->query('SELECT * FROM movies LIMIT '.$offset.','.$limit); foreach($q->result() as $row) { $data = array( 'films_id' => $row->id, 'films_name' => $row->name, 'films_duration' => $row->duration ); $this->db->insert('films', $data); } } // two optional lines: $q->free_result(); unset($q); $offset = $offset+$limit; header("Location: $url/$off/$limit/$stop"); } } ?>
Now, to start copying fields from movies to films you will write the initial url into your browser:
http://www.rahmetli.info/codeigniter/copyTable/moviesToFilms/OFFSET_VALUE/LIMIT_VALUE/STOP_VALUE
For example:
http://www.rahmetli.info/codeigniter/copyTable/moviesToFilms/0/100/6000
Means that start getting fields from 0th row and continue until 6000th row by 100 rows each time. So the script will run (6000/100 =) 6 times and stop at:
http://www.rahmetli.info/codeigniter/copyTable/moviesToFilms/6000/100/6000
That’s it.
Haydarpaşa is one of the major stations in Istanbul, Turkey because of its location and mission. Being a transportation hub makes it the busiest station of Istanbul so that it provides both domestic and international transportation options. It is also being used for both public transportation and active trading (Turgut 192). It is not only a railway station but also a seaport. Before Haydarpaşa met its magnificent building it was just the center of trading during the Ottoman Empire (Quataert 147). After a while Haydarpaşa became one of historical places in Turkey. Its history, value and importance will be detailed in further paragraphs of this article.
Before Haydarpaşa terminus was built in Istanbul, there was not any trading going on (Quataert 141). In a manner, there was not any railway too. During that period when the Ottoman Empire had a bad economic condition because of wars, Deutsche Bank and the government of the Ottoman Empire decided to sign an agreement to construct Anatolian Railway in 1888 (Quataert 139). That starting progress also took the attention of European investors that was meaning a huge amount of profit for the government (Quataert 139). Addition to this, the Ottoman Empire expanded the agreement to build railways to Konya after connecting Istanbul to Ankara (Quataert 147). That construction started a new era of trading and transporting for Turkey because Istanbul would be a good incoming source for the economics.
Railroads had an important place in the economic development of many countries throughout Europe and America. Behind economics, the help of railroads also improved social and cultural interactions (Quataert 141). The Ottoman Empire had same plans to engage with those improvements but underdevelopment of the Ottoman government lead to dilemma (Quataert 142). The other problem of the Ottoman Empire was also being in wars; therefore Turkey needed to benefit the railroad for strategic purposes such as transporting supply for the army and transferring soldiers to the field (Quataert 159). The government dedicated to the railroad to agriculture and mining sectors when the railroad was ready for public use (Quataert 142).
Not only German companies took advantage of the railroad, but also Americans with The Chester Project tried to construct further railways to reach east of the Ottoman Empire. The project’s name comes from Admiral Colby M. Chester. During his visit to Turkey, Young Turks were the actors of the revolution in 1908 and their promise was to modernize Turkey starting from economic development by extending railroad constructions and developing ports (DeNovo 302). This seemed like an advantage in the eye of Chester but in the end he and his team are defeated by German imperialism and the lack of business support from America (DeNovo 300). His main purpose to build railroads was to control mining ventures and that was not only his idea but also all of investors’.
After completing the web of railroad through Anatolia, Sultan Abdulhamid II made a speech that “I built all those railroads and buildings for the port, but it is not still enough. We shall build such a building that it will prove the grandiosity of what we did” (“Haydarpaşa”). On the demand of Sultan, the construction of Haydarpaşa building was started by two German architectures Otto Ritter and Helmuth Conu in 1906. During the construction, skillful Italian and German sculptors worked together and Haydarpaşa building was completed after two years, in August 1908. The architectural style of Haydarpaşa has Neo Classic German figures as expected. Whole building was constructed on 1100 wooden units which each of them is 21 meters and it has two magnificent towers at the front side. The building was constructed on the area of 2525 square meters but it is spread to 3836 with closed sections.
The name of building is coming from Sultan Selim III who was named “Haydar Paşa”. He had spent most of his time to achieve constructing Selimiye military headquarters and some section of Haydarpaşa took his name in response to his struggle. After a while, authorities decided to give his name to whole building.
Haydarpaşa is still alive after more than one hundred year but it could not remain being fully original because of disasters it faced. First one was an explosion on September 6, 1917 that sounded like a sabotage to destroy main transportation building of Turkey. After that explosion, the roof of Haydarpaşa burnt down and also other sections were damaged. This is not the only disaster it faced in the past; there was a sea accident occurred by a striking tanker in 1979. The stained glasses of Haydarpaşa were damaged in that event but they were replaced with the copies of originals.
Today, Haydarpaşa station is trying to leave all disasters in the past with the help of restorations and have a bright future, but it seems impossible while the government “unofficially” tries to fish on troubled waters. What the government tries to imply is turning Haydarpaşa station into World Trade Center that covers approximately 1.000.000 square meters. Those buildings of five star hotels, skyscrapers, sports and recreation facilities that are planning to be built around Haydarpaşa station would definitely kill the perfect view of Haydarpaşa (Turgut 192). Throwing everything to wind, along a coastal city like Istanbul that has a huge earthquake risk cannot handle that kind of project and it is also violating the Coastal Code of Turkey (Turgut 193).
While the storm is brewing, Haydarpaşa station faced another disaster on November 29, 2010. Was it coincidence? Maybe or maybe not but watching that magnificent building sweeping up the ashes deeply broke the hearts. Sadly, the roof of Haydarpaşa station burnt down for the second time, but its towers were still standing with all of their powers. “Time has stopped at 3.17” said the newspaper Hürriyet, and continued: “For Istanbul’s historical Haydarpaşa train station, the exact minute the building’s roof caught fire Sunday evening (Şenerdem par. 1). But it is not just the clock on the building’s front façade that has stopped: Life has also halted at Haydarpaşa” (Şenerdem par. 1). The key word of that new was “life” because hundreds of passengers uses that station to meet with their lovers, to catch up their works, to travel across the cities. Haydarpaşa has a special place in Turkish people’s hearts, and Sadiye Çoplan who was the witness of that event proved this by saying “I burst into tears when I saw Haydarpaşa burning, it carries value that cannot be bought with money” (Şenerdem par. 2). It is not a building anymore but a breathing creature of Istanbul; therefore seeing Haydarpaşa as a rent-making target as Mehmet Zazan also agrees is a big threat for Istanbul. Then he adds, “It is a shame they did not extinguish the fire from the air” (Şenerdem par. 3).
If the government’s or some people’s secret plan on converting Haydarpaşa into a tourist or a commercial center becomes successful, a lot of people will become unemployed. The workers of Haydarpaşa do not work only for money as Mrs. Çoplan emphasized on above, they are also proud of being the part of this dear station (Şenerdem par. 2). In the documentary of Haydarpaşa station, named “Haydarpaşa”, made by TRT (Turkish Radio and Television) one of the machinists tried to explain his feeling while driving a train: “My current mission is bring people together, with their lovers. I serve to the community. When I am off, I go to the coast side of Haydarpaşa and watch the beauty of sea, its waves, and flying seagulls. Watching the passengers coming from ferries and going to the trains we drive is a unique pleasure I cannot describe. I think it is peaceful.”
The distant memories, which Haydarpaşa has, cannot be described. You should spend one day there to understand what the words you are reading mean: A passenger carrying a sleeping baby, the crowd trying to catch trains, magnificent historical pieces of the building, people who could not see their relatives for years or who will not see for years. You can even see a couple getting married in the backyard of Haydarpaşa. Before you leave, because travelling with trains costs less than other transportations, you can see a poor family trying to manage with 6 members. Different lives are getting combined in one place, Haydarpaşa, and it is the last place people hold something; maybe a hand or a body (“Haydarpaşa”).
In the documentary, Adnan Başaran who is the founder of Turkish Union of Railwaymen cried while he is trying to “describe” the meaning of Haydarpaşa for himself but he could not: “I love Haydarpaşa workers (family) as my own son. Haydarpaşa is very beautiful, but it cannot be described”. Muhtar Erol, the current president of TCDD (Turkish State Railways), is better than Başaran on describing the importance of Haydarpaşa by saying “It was in the themes of books and movies, the inspirer for painters and composers. That kind of magic Haydarpaşa has.” Why cannot people easily describe Haydarpaşa is that its value in every person’s life differs. It depends on the time you met with Haydarpaşa and it depends also on the reason why you met with Haydarpaşa. Some people are fascinated by its historical beauty; some has unforgettable memories like I do.
Haydarpaşa station is a remarkable historical building of Turkey that is connected to the web of railways mostly built by Germans. It carries a lot of memories of war, love and nostalgia. Despite of those memories, it is also an important source of economics for Turkey because of being a connection between the land and sea, and having a seaport. Unless the government tries to build a commercial thing such as a hotel instead of keeping Haydarpaşa as a train station, it will remain being that meaningful historical building
Bibliography:
DeNovo, John A. “A Railroad for Turkey: The Chester Project, 1908-1913” The Business History Review 33 (1959): 300-329. Print.
Haydarpaşa. Prod. Şükran Bircan Özmen, Dir. Ömer Özmen. TRT, 2008. DVD.
Quataert, Donald. “Limited Revolution: The Impact of the Anatolian Railway on Turkish Transportation and the Provisioning of Istanbul, 1980-1908” The Business History Review 51 (1977): 139-160. Print.
Şenerdem, Erisa Dautaj. “Istanbul’s Haydarpaşa train station sweeps up the ashes.” Hürriyet Daily News 29 Nov. 2010. Web. 22 March 2011.
Turgut, S. “What the new Istanbul shaped by capital makes one think…” The Sustainable city IV: urban regeneration and sustainability 93 (2006): 189-197. Print.
Unur, A. Sinan. Plaques installed on the façade. [c. 1970]. Haydarpaşa Station. Unur. Web. 18 March 2011.
The collected links of sources to check:
Written sources and photos (figure 3): http://goo.gl/yg23n and http://goo.gl/hLOry
Hürriyet source: http://goo.gl/drYmU
Documentary source of TRT (DVD) YouTube links:
http://www.youtube.com/watch?v=6lLZQGA7HZI
Photos: http://prospektus.tumblr.com
To gain a bit of knowledge about Visual Basic, I tried to code a simple Hangman game. Before learning something about Visual Basic, I had to install Vindovs XP on Mac to set up Visual Basic 2010 Express (requires Service Pack 3). As you all know I hate Vindovs, so I thought I would never come across it again.
Coding in Visual Basic is quite simple. My preference was “Form Application” (Windows Forms) so what I learned addition to my knowledge:
Use Dim to declare a variable, array, anything:Dim myNumber As Integer or Dim myName or Dim myArray() As Button
Use ReDim to re-define an array:ReDim myArray(13)
Use Sub to declare names, parameters and codes:Private Sub calculateSquare(ByVal value As Integer)
' square is a variable defined in class
square = value * value
End Sub
Functions cannot return void, using Sum is an option for void functions as shown above:Function calculateSquare(ByVal value As Integer) As Integer
Dim output = value * value
return output
End Function
Other than that event handlings are quite same like other languages such asPrivate Sub Button1.Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.click
Design Objects
Hangman shape:
LineShape1 (|), LineShape2 (-), LineShape3 (|), LineShape4 (OvalShape), LineShape5 (|), LineShape6 (\), LineShape7 (/), LineShape8 (\), LineShape9 (/)
Output labels and panel:
Label1 (output), result (RESULT), errorPanel (covering buttons to prevent clicking), puanLabel (Score:), puan (000), Label2 (signature)
Buttons (letters):
Button1 (A), Button2 (B), Button3 (C), … , Button29 (Z)
Control Buttons
NewGame (New Game), ExitGame (Exit Game)
Form Code with comments
Public Class Form1 ' author: emin buğra saral ' version: 1.0 date: May 3, 2011 ' .NET version: 4.0 Dim wrongLetter As Integer = 0 'the number of how many times the man was hanged Dim word As String ' the word taken from wordlist (listbox) Dim screen() As String ' the screen array (kind of list) Dim output As String ' output which will be printed as _ _ _ A _ but it will get its value from screen array Dim known = 0 ' how many letters known Dim length = 0 ' how many letters there are in total Dim score = 0 ' score ' when the program run, this Load method will be called initially (main method) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' call initial methods and hide the list (methods are below, check them for descriptions) createList() resetMan() ' at first, hide list, the alert text (WIN, LOSE ETC) and the panel covering the buttons wordList.Visible = False result.Visible = False errorPanel.Visible = False Randomize() ' needed to get different random numbers at each new run (closing and openings, not new games) word = generateRandomWord() ' get first word and delete it from list, attach it to word length = Len(word) ' Len() method gets the length of arrays or strings ReDim screen(length) ' each time when ReDim is being used, it changes them in length with given value which is Length resetScreen() ' reset the output according to screen array puan.Text = score ' puan is the label on the left bottom corner which shows score End Sub ' we will handle all of the buttons as you see here after Handles. when one of them gets used, sender Object will refer to that clicked one Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click, Button9.Click, Button10.Click, Button11.Click, Button12.Click, Button13.Click, Button14.Click, Button15.Click, Button16.Click, Button17.Click, Button18.Click, Button19.Click, Button20.Click, Button21.Click, Button22.Click, Button23.Click, Button24.Click, Button25.Click, Button26.Click, Button27.Click, Button28.Click, Button29.Click sender.Enabled = False Dim found = False ' that one will show if the word includes that button (letter) For i As Integer = 0 To Len(word) - 1 ' look over all of the letters in word If word(i) = sender.Text Then ' when ith letter of word equals to the clicked one (sender.text) found = True ' change found to true known = known + 1 ' increse the number of known letters screen(i) = word(i) + " " ' change ith _ (line) with that letter in screen array End If Next If (found = True) Then If (known = length) Then ' if all the letters are known winInfo() ' show win Else ' other wise create output again by using screen which is changed above, same procedure like in load method resetScreen() End If Else 'if the user couldnt find the letter, increase the number of wrongLetter and use hangMan method. check this method for detail because it uses wrongLetter wrongLetter = wrongLetter + 1 hangMan() End If End Sub ' make all buttons enabled : you can create an array too Private Sub refreshButtons() Button1.Enabled = True Button2.Enabled = True Button3.Enabled = True Button4.Enabled = True Button5.Enabled = True Button6.Enabled = True Button7.Enabled = True Button8.Enabled = True Button9.Enabled = True Button10.Enabled = True Button11.Enabled = True Button12.Enabled = True Button13.Enabled = True Button14.Enabled = True Button15.Enabled = True Button16.Enabled = True Button17.Enabled = True Button18.Enabled = True Button19.Enabled = True Button20.Enabled = True Button21.Enabled = True Button22.Enabled = True Button23.Enabled = True Button24.Enabled = True Button25.Enabled = True Button26.Enabled = True Button27.Enabled = True Button28.Enabled = True Button29.Enabled = True End Sub ' generate new word from list randomly and delete it from list Function generateRandomWord() As String ' if there is enough word left If (wordList.Items.Count > 0) Then Dim r = Int(Rnd() * (wordList.Items.Count - 1)) ' generate random number between 0 and total number of list minus 1 Dim word = wordList.Items.Item(r) ' set the word at "random" position wordList.Items.RemoveAt(r) ' delete it from list Return word ' send the word outside Else ' CStr changes any value from double , int, or char to String. ' vbCrLf : new line MsgBox(CStr("No More Words. Goodbye") + vbCrLf + CStr("Score: ") + CStr(score)) End End If End Function ' hide the man Private Sub resetMan() LineShape1.Visible = False LineShape2.Visible = False LineShape3.Visible = False LineShape4.Visible = False LineShape5.Visible = False LineShape6.Visible = False LineShape7.Visible = False LineShape8.Visible = False LineShape9.Visible = False End Sub ' if the man is hanged 9th time, it means loseInfo needs to be called Private Sub hangMan() Select Case wrongLetter Case 1 LineShape1.Visible = True Case 2 LineShape2.Visible = True Case 3 LineShape3.Visible = True Case 4 LineShape4.Visible = True Case 5 LineShape5.Visible = True Case 6 LineShape6.Visible = True Case 7 LineShape7.Visible = True Case 8 LineShape8.Visible = True Case 9 LineShape9.Visible = True loseInfo() End Select End Sub ' adds each word to wordList (listbox) by using its own methods, you can also get words from a text file Private Sub createList() wordList.Items.Add("WORDONE") wordList.Items.Add("WORDTWO") wordList.Items.Add("WORDTHREE") wordList.Items.Add("...") End Sub Private Sub winInfo() errorPanel.Visible = True result.Visible = True result.ForeColor = Color.Green result.Text = "WIN! :)" resetScreen() score = score + 10 puan.Text = score End Sub Private Sub loseInfo() errorPanel.Visible = True result.Visible = True result.Visible = True result.ForeColor = Color.Red result.Text = "LOSE! :(" resetScreen() score = score - 10 puan.Text = score End Sub Private Sub ExitGame_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitGame.Click End End Sub Private Sub NewGame_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewGame.Click ' reset everything wrongLetter = 0 known = 0 length = 0 word = generateRandomWord() length = Len(word) errorPanel.Visible = False result.Visible = False resetMan() refreshButtons() resetScreen() End Sub Private Sub resetScreen() output = "" For i As Integer = 0 To length - 1 screen(i) = "_ " ' screen(i) means i'th element of screen array output = output + screen(i) ' attach that element to output with output's current value. initial value of output is "" which means empty Next Label1.Text = output ' send it to form End Sub End Class
Note: You can create your own design file according to design objects I shared above, so I won’t share it here.
Another Note: You can use VB 6.0 to use Control Arrays efficiently which would reduce the amount of code.
Most important note: Never use Vinvods.
Adam Asmaca Visual Basic 2010 Express.
The author
Matt Mullenweg
Purpose
bbPress is plain and simple forum software, plain and simple.
Translation Date
May 2011
Underwork
Using bbPress’ own .pot file, translated with P0edit from English to Turkish.
Site URL
http://rahmetli.info/forum/topic/bbpress-103-turkish-turkce
Doing the same things over and over is not an option for lazy web users like me. Switching between tabs is easy by using “control + tab” or “control + shift + tab” combinations but most of you would prefer using the mouse in practice.
Firefox 4 will be the most popular browser in a few months (as I hope) and I’d like to see my request in its future add-ons (or extensions). Or is there already one?
Situation:
Lets assume you are listening music in one tab (thesixtyone.com) and on the other hand you are looking for your favorite movies in other tab (imdb.com). You wanted to watch a movie (trailer) but the music is playing so you wouldn’t hear anything. What you would do is either closing other tab or switch to it to pause and come back to the movie. It seems quite easy but repeating that action every time you want to watch something becomes annoying.
My request in idea:
I don’t want to switch to another tab to play/pause the music. Tabs should have play/pause buttons on them so I would spend only one click (kind of an onHover event). Here is the example:
First thing came to my mind:
By using javascript (or anything else), keyboard shortcuts can be manipulated to take actions on webpages. For example most of the music websites using “space” as a play/pause trigger. That play/pause button which tabs will have would trigger “space”. The websites using a specific html meta tag would have that feature. Of course there may be more useful ways to achieve that.
Hope someone comes out with that add-on, I’m looking forward to use it. :)
Born.
Learn the rules.
Follow them.
Love.
Get hurt.
Fool yourself.
Love again.
And again.
Quit.
Just fuck them.
Name it something else.
Fool yourself again.
Be happy.
Live it.
Then fake it.
Look for new words.
Describe it.
Name it love again.
The end.
Hate it both.
Then kick it.
Face it in the morning.
Cry.
Kick yourself.
Into another world.
Use the words you found.
Create if you did not.
Love the same gender.
Try.
See what is wrong.
Damn, describe it again.
Tell the truth.
Love a lesbian.
Watch her fucking somebody.
Forget the jealousy.
Pure reality.
Kiss the feeling.
Fuck the believing.
Forget everything.
Name it nothing.
And obey nothing.
But her body.
Adore it.
Just her existence.
Worship it.
Close your eyes.
Wear your blinkers.
Open your chest.
Or let her do.
Breathe her and sleep.
Wake up.
Tell me what you see.
Nothing?
Don’t, go back to sleep.
Me, and my family decided to visit one sweet couple of our relatives living in Sarp, Artvin. While the trip took so long, I enjoyed most of it by taking that short movie:
This AppleScript code asks user for brightness and contrast values for the selected image in Adobe InDesign CS4 and then apply the adjustment values to that image by using Adobe Photoshop CS4.
Script Download link: http://www.rahmetli.info/docs/AdjustBrightnessContrast.zip
Example video: http://screencast.com/t/tt1zTydBSJ
Here is the open source code:
-- Author : Emin Bugra Saral -- Author Website : http://www.rahmetli.info -- Sources : http://www.adobe.com/products/indesign/scripting/pdfs/InDesignCS4_ScriptingGuide_AS.pdf -- Purpose : Changing brightness and contrast of an image in InDesign CS4 by using Photoshop CS4 -- Warning: Please be sure you read "readme.txt" tell application "Adobe InDesign CS4" activate -- default values : set defaultBValue to 80 set defaultCValue to 0 set defaultSaveValue to false -- create dialog set adjuster to make dialog tell adjuster -- title set name to "Brightness and Contrast settings for Photoshop CS4" set myColumn to make dialog column tell myColumn -- bordered area, asking for values set myBorder to make border panel tell myBorder make static text with properties {static label:"Brightness Level % "} set brightnessLevel to make integer editbox with properties {edit value:defaultBValue} make static text with properties {static label:"Contrast Level % "} set contrastLevel to make integer editbox with properties {edit value:defaultCValue} end tell -- unbordered area, asking before saving set saving to make checkbox control with properties {static label:"Ask me before saving", checked state:defaultSaveValue} -- showing limits make static text with properties {static label:""} make static text with properties {static label:"Brightness must be between -150 and 150"} make static text with properties {static label:"Contrast must be between -50 and 100"} end tell end tell -- InDesign - Photoshop controlling if selection = {} then -- if nothing is selected display dialog "You did NOT select anything!" with icon 0 else if class of item 1 of selection is in {rectangle, oval, polygon} or class of item 1 of selection is in {image, PDF, EPS} then -- checking if the image is directly selected or not if class of item 1 of selection is in {rectangle, oval, polygon} then -- frame set imageLink to item link of graphic 1 of selection set imagePath to file path of item link of graphic 1 of selection else if class of item 1 of selection is in {image, PDF, EPS} then -- directly set imageLink to item link of item 1 of selection set imagePath to file path of item link of item 1 of selection end if -- myStatus holds for controlling input errors, to continue the while loop set myStatus to true repeat while myStatus is true set showAdjuster to show adjuster -- if user pressed OK if showAdjuster is true then -- saving result check to define parameter will be used in PS CS4 if checked state of saving is true then set savingParam to ask else set savingParam to yes end if -- initialize error message set errorMsg to null -- define variables from inputs which will be used in PS CS4 set theBrightness to edit value of brightnessLevel set theContrast to edit value of contrastLevel -- some logic statements if theBrightness is 0 and theContrast is 0 then set myStatus to false destroy adjuster else if theBrightness > 150 then set errorMsg to "Brightness Level cannot be greater than 150" set edit value of brightnessLevel to 150 else if theBrightness < -150 then set errorMsg to "Brightness Level cannot be less than -150" set edit value of brightnessLevel to -150 else if theContrast > 100 then set errorMsg to "Contrast Level cannot be greater than 100" set edit value of contrastLevel to 100 else if theContrast < -50 then set errorMsg to "Contrast Level cannot be less than -50" set edit value of contrastLevel to -50 else -- stop while loop and open PS CS4 set myStatus to false destroy adjuster tell application "Adobe Photoshop CS4" activate open file imagePath -- adjustment function with parameters taken above adjust current layer of the current document using brightness and contrast with options {class:brightness and contrast, brightness level:theBrightness, contrast level:theContrast} -- saving with the parameter taken above close document 1 saving savingParam end tell -- time to pass on InDesign CS4 tell application "Adobe InDesign CS4" activate -- refresh the image relink imageLink to file imagePath end tell end if -- if there was any error in logic, show it to the user if errorMsg is not null then display dialog errorMsg with icon 0 end if else -- if the user pressed CANCEL, destroy everything and stop while loop destroy adjuster set myStatus to false end if end repeat else -- if the selected thing is neither an image's frame nor image display dialog "Please select an image frame!" with icon 0 end if end tell
WARNING: PLEASE SAVE YOUR WORKSPACE/DOCUMENT BEFORE USING THE SCRIPT!
NOTE: Because InDesign CS4 can not update modified links with AppleScript, you must manually update the links (how to?).
REMINDER: First of all, you must be using Photoshop CS4 and InDesign CS4 for “MACINTOSH” to run this script. If you use any other version than those applications, change the version of applications in script file (For example: tell application “Adobe Photoshop CS3″) If this also does not work, then you must change whole code after reading script guidelines of Adobe.
Installing and using the script in steps:
- Copy the script file under “/Users/user/Library/Preferences/Adobe InDesign/Version 6.0/en_GB/Scripts/Scripts Panel”
- To use script, follow “Window->Automation->Scripts” menu in InDesign
- Then, double-click on the script to apply it.
PLEASE share your idea, add something, improve the code by writing a comment.
After seeing this post, I decided to organize my desktop too. But instead of using a wallpaper, I tried GeekTool which is a desktop organizer tool. By using that pretty System Preferences Module, you can add shell commands, text files, or images to your desktop. What I did is creating a few titles and placing them on different places of my desktop; more like I categorized my desktop. And later, I added date on right bottom corner. Then at last, I added an image to right top corner which it will point the last file created on desktop. It is actually not necessary, but it’s a concentration mark to remind you organizing your folders always :)
If you would like to download Geek Tool files which I used, here’s the download link.
Note: Display resolution is 1440 x 900.
After reading this post I decided to write a script to edit an image of InDesign with Photoshop. So this script saves me from “right click -> edit with -> Adobe Photoshop CS4” path, and directly opens the image in Photoshop.
Script Download link: http://www.rahmetli.info/docs/editWithPhotoshop.zip
Example video: http://screencast.com/t/BBYqjXai
Here is the open source code:
-- Author : Emin Bugra Saral -- Author Website : http://www.rahmetli.info -- Sources : http://macscripter.net/viewtopic.php?id=31867 -- Purpose : Automatically open with Photoshop CS4 in InDesign CS4 script -- Warning: Please be sure you read "readme.txt" tell application "Adobe InDesign CS4" activate if selection = {} then -- if nothing is selected display dialog "You did NOT select anything!" with icon 0 else if class of item 1 of selection is in {rectangle, oval, polygon} then -- if the image's frame is selected set imagePath to file path of item link of graphic 1 of selection tell application "Adobe Photoshop CS4" activate open file imagePath end tell else if class of item 1 of selection is in {image, PDF, EPS} then -- if the image is selected set imagePath to file path of item link of item 1 of selection tell application "Adobe Photoshop CS4" activate open file imagePath end tell else -- if the selected thing is neither an image's frame nor image display dialog "Please select an image frame!" with icon 0 end if end tell
WARNING: PLEASE SAVE YOUR WORKSPACE/DOCUMENT BEFORE USING THE SCRIPT!
REMINDER: First of all, you must be using Photoshop CS4 and InDesign CS4 for “MACINTOSH” to run this script. If you use any other version than those applications, change the version of applications in script file (For example: tell application “Adobe Photoshop CS3″) If this also does not work, then you must change whole code after reading script guidelines of Adobe.
Installing and using the script in steps:
- Copy the script file under “/Users/user/Library/Preferences/Adobe InDesign/Version 6.0/en_GB/Scripts/Scripts Panel”
- To use script, follow “Window->Automation->Scripts” menu in InDesign
- Then, double-click on the script to apply it.
PLEASE share your idea, add something, improve the code by writing a comment.