Very sad news indeed. :(
Future GPU Thoughts and Musings: End of an Era - Aces Studio and Flight Sim shuttered
Saturday, January 24, 2009
Friday, January 02, 2009
Watching Remote Logs
We sometimes need to monitor log files on remote servers.
A simple method, that doesn't require us to log in to the remote host, is to run GNU tail command over the network using ssh.
Example, if we want to monitor the file /var/log/sample.log on the remote host hostname.
A simple method, that doesn't require us to log in to the remote host, is to run GNU tail command over the network using ssh.
Example, if we want to monitor the file /var/log/sample.log on the remote host hostname.
$ ssh hostname tail -retry -follow=name /var/log/sample.log
Saturday, December 20, 2008
UNIX time to human readable
You can easily convert a UNIX time to human readable using the shell command date.
$ date -d @1212312323
Sun Jun 1 13:25:23 GST 2008
Sunday, November 30, 2008
How to have Undelete on your Linux command line.
Almost all distro now has a Trash to undo your current deleted files when using the GUI file browsers.
When you spend most of your time on the shell you usually use the command "rm" to delete a file and this command doesn't support undelete once you issued the command.
First we need to learn not to use the command 'rm' to delete our files.
In your ~/.bashrc file add the following line:
Then we need a script to clean up our trash folder occasionally.
Create a script and name it whatever you want, I named mine "cleantrash" and have the code below inside it.
Make sure you do a
When you spend most of your time on the shell you usually use the command "rm" to delete a file and this command doesn't support undelete once you issued the command.
First we need to learn not to use the command 'rm' to delete our files.
In your ~/.bashrc file add the following line:
alias del='mv -t ~/.local/share/Trash/files --backup=t'Deleting files now is done via
del filename.txt.
Then we need a script to clean up our trash folder occasionally.
Create a script and name it whatever you want, I named mine "cleantrash" and have the code below inside it.
#!/bin/bash
#
# This will delete all files in the trash directory
# that is older than the specified KEEPDAYS
#
# It can be run using a cron job or manually
#
TRASHDIR=~/.local/share/Trash/files/
KEEPDAYS=14
find $TRASHDIR -mtime +${KEEPDAYS} -exec /bin/rm -f {} \;
Make sure you do a
chmod +x cleantrash so we can execute it.
Sunday, November 23, 2008
CakePHP Ajax Login using Auth Component.
Need to update a login controller/view to have AJAX login capability without too much changes to the view and controllers.
Above code are typical Users controller and view files.
What we need:
Changes we need to implement:
There is no need to make changes to the default layout since the JQuery helper already includes the jquery library in the head of the layout.
The jquery library being loaded by the helper is hard coded so you need to make sure you got the correct jquery version in your /app/webroot/js folder.
The code also redirects to the root folder on successful authentication.
Controller
app/controllers/users_controller.phpclass UsersController extends AppController {
var $name = 'Users';
var $helpers = array('Html', 'Form');
var $components = array('Auth');
function beforeFilter() {
parent::beforeFilter();
Auth->allow('logout');
}
function login(){
if ($this->Auth->user()) {
$this->User->id = $this->Auth->user('id');
$this->User->saveField('last_login', date('Y-m-d H:i:s'));
$this->Session->setFlash(sprintf("Welcome %s!", $this->Auth->user('username')));
$this->redirect('/');
}
}
function logout() {
$this->Session->destroy();
$this->redirect('/');
}
}
View
views/users/login.ctp <div id="login-dialog">
<?php echo $form->create('User', array('action'=>'login'))?>
<?php flash('Auth.login'); ?>
<?php echo $form->input('username');?>
<?php echo $form->input('password', array('type' => 'password'));?>
<?php echo $form->submit('Login');?>
<?php echo $html->link('Forgot my password', array('action' => 'forgot_password'));?>
<?php echo $form->end();?>
<?php echo $html->link('Register', array('admin' => false, 'action' => 'register'));?>
</div>
Above code are typical Users controller and view files.
What we need:
- Latest Jquery to make life easy. Save it to your app/webroot/js folder.
- Form plugin to make dealing with form easy. Save it to your app/webroot/js folder.
- JQuery Helper to make using JQuery with CakePHP easy.
Changes we need to implement:
- Add the RequestHandler component to our app_controller.php or to the UsersController.
var $components = array('Auth', 'RequestHandler'); - Add the JQuery helper to our helpers.
var $helpers = array('Html', 'Form', 'Jquery');
Make sure to download the jquery helper from the link above and put it in your "app/views/helpers/" folder. - Add the code below:
Controller changes:
function login(){
if ($this->Auth->user()) {
$this->User->id = $this->Auth->user('id');
$this->User->saveField('last_login', date('Y-m-d H:i:s'));
$this->Session->setFlash(sprintf("Welcome %s!", $this->Auth->user('username')));
$this->redirect('/');
}
if ($this->RequestHandler->isAjax()) {
header('HTTP/1.0 401 Unauthorized');
die();
}
}
View file changes
<div id="login-dialog">
<?php echo $form->create('User', array('action'=>'login'))?>
<?php flash('Auth.login'); ?>
<?php echo $form->input('username');?>
<?php echo $form->input('password', array('type' => 'password'));?>
<?php echo $form->submit('Login');?>
<?php echo $html->link('Forgot my password', array('action' => 'forgot_password'));?>
<?php echo $form->end();?>
<?php echo $html->link('Register', array('admin' => false, 'action' => 'register'));?>
</div>
<?php
$loginURL = Router::url(array('controller' => 'users', 'action' => 'login'));
$jquery->uses('jquery.form');
$jquery->addScript(
' var options = {',
' url: "'.$loginURL.'",',
' success: function(data, statusText){',
' window.location = "/";',
' },',
' error: function(XMLHttpRequest, textStatus, errorThrown){',
' alert("Invalid Username and Password");',
' },',
' };',
' $("form#UserLoginForm").ajaxForm(options);'
);
?>
There is no need to make changes to the default layout since the JQuery helper already includes the jquery library in the head of the layout.
The jquery library being loaded by the helper is hard coded so you need to make sure you got the correct jquery version in your /app/webroot/js folder.
The code also redirects to the root folder on successful authentication.
Need proxy? Lowest priced starting at $0.71/proxy. Insane!
Buy Instagram Followers
Subscribe to:
Posts (Atom)
