Skip to content

Instantly share code, notes, and snippets.

View amirkheirabadi73's full-sized avatar
🙃
confused about future

Amir amirkheirabadi73

🙃
confused about future
View GitHub Profile
@amirkheirabadi73
amirkheirabadi73 / Static Drop Down
Created June 16, 2013 07:57
Create DropDown Menu Item Function In Mode()
model :
const type_one = 1;
const type_two = 2;
const type_three = 3;
public function getType(){
return array(
self::type_one => "one",
self::type_two => "two",
@amirkheirabadi73
amirkheirabadi73 / Set filed Befor Seve record
Created June 17, 2013 07:40
Set Filed Befor Save Record
mode () :
protected function beforeSave()
{
if(parent::beforeSave())
{
if($this->isNewRecord)
{
$this->create_time=$this->update_time=time();
$this->author_id=Yii::app()->user->id;
@amirkheirabadi73
amirkheirabadi73 / Mongodb Cloud Data Base ( Insert ) With Mongoose
Created June 18, 2013 12:37
Monfo DB Connected With Cloud Data Base Mongo And Insert Collection To Data Base ....
/**
* Module dependencies.
*/
var express = require('express');
var routes = require('./routes');
var fs = require("fs");
var mongoose = require('mongoose');
@amirkheirabadi73
amirkheirabadi73 / Model ...
Created June 23, 2013 12:31
User Authentication ....
public function validatePassword($password)
{
return $this->hashPassword($password)===$this->password;
}
public function hashPassword($password)
{
return md5($password);
}
@amirkheirabadi73
amirkheirabadi73 / MongoDB
Created June 25, 2013 15:58
List All Command In MongoDb
show dbs
// LIst Data Base
show collections
// List Collections
use test
// Select Db
db
@amirkheirabadi73
amirkheirabadi73 / How to use the path module?
Created July 2, 2013 05:26
FS System ... Read And Write In txt ANd Json File
var path = require('path');
path.normalize('/a/.///b/d/../c/')
'/a/b/c/'
// '.' for 'this directory' and '..' for 'one level up'
var path = require('path');
var url = '/index.html';
path.join(process.cwd(), 'static', url);
'/home/nico/static/index.html'
@amirkheirabadi73
amirkheirabadi73 / All Api FS
Created July 2, 2013 05:59
All Api For File System
fs.rename(oldPath, newPath, callback)#
Asynchronous rename(2). No arguments other than a possible exception are given to the completion callback.
fs.renameSync(oldPath, newPath)#
Synchronous rename(2).
fs.ftruncate(fd, len, callback)#
Asynchronous ftruncate(2). No arguments other than a possible exception are given to the completion callback.
fs.ftruncateSync(fd, len)#
@amirkheirabadi73
amirkheirabadi73 / Watch File
Created July 2, 2013 06:28
Watch A File For Changes RealTime
var fs = require("fs");
console.log("Read File ....");
var conf = JSON.parse(fs.readFileSync("config.json"));
console.log("One : ", conf);
fs.watchFile("config.json", function(current,previous){
console.log("File Changed ...");
var conf = JSON.parse(fs.readFileSync("config.json"));
console.log("Two : " , conf);
});
@amirkheirabadi73
amirkheirabadi73 / Simple Sever http
Created July 2, 2013 06:30
Simple Sever http For Print Hello World In Screen
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
@amirkheirabadi73
amirkheirabadi73 / Show Image
Created July 11, 2013 05:32
Show Image In Screen
from kivy.app import App
from kivy.uix.image import Image
from kivy.uix.widget import Widget
class showimage(Image):
pass
class MyApp(App):
def build(self):