Skip to content

Instantly share code, notes, and snippets.

View duyet's full-sized avatar

duyet duyet

View GitHub Profile
CREATE TABLE SanPham(
MaSP int primary key not null,
TenSP varchar(50),
SoLuongTon int,
MaLoai varchar(50)
)
CREATE TABLE NhanVien(
MaNV int primary key not null,
HoTen varchar(50),
@duyet
duyet / youtube_action_delete_live_event
Created April 2, 2015 05:53
Remove Any Youtube Video via Youtube API
POST https://www.youtube.com/live_events_edit_status_ajax?action_delete_live_event=1
event_id: ANY_VIDEO_ID
session_token: YOUR_TOKEN
Response :
{
"success": 1
}
@duyet
duyet / git-pull-force.sh
Last active August 29, 2015 14:18 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@duyet
duyet / exec_java_on_nodejs.js
Created April 11, 2015 03:20
Exec Nodejs on Nodejs Application.
var spawn = require('child_process').spawn;
var prc = spawn('java', ['-jar', '-Xmx512M', '-Dfile.encoding=utf8', 'script/importlistings.jar']);
//noinspection JSUnresolvedFunction
prc.stdout.setEncoding('utf8');
prc.stdout.on('data', function (data) {
var str = data.toString()
var lines = str.split(/(\r?\n)/g);
console.log(lines.join(""));
});
<?php
include('config.php');
try {
$pdo = new PDO("mysql:host=$hostname;dbname=$dbname;charset=utf8", "$username", "$pw", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$pdo->exec("set names utf8");
$pdo->exec("set character_set_client='utf8'");
$pdo->exec("set character_set_results='utf8'");
$pdo->exec("set character_set_connection='utf8_general_ci'");
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
} catch(PDOException $e) {
#! /bin/sh
usage_error () {
echo 'Usage: sh migrator.sh <path to sqlite_to_postgres.py> <path to sqlite db file> <an empty dir to output dump files>'
echo
echo 'Example:'
echo '>sh migrator.sh sqlite_to_postgres.py ~/reviewboard.db /tmp/dumps'
echo
echo 'Tested on:'
echo 'Python 2.7.3'

Gitlab Gmail configuration

In Gitlab 2.6 you must edit the following files in order to send messages through a Gmail account (also applicable to Google Apps accounts).

config/environments/production.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
@duyet
duyet / ajax.php
Created May 20, 2015 12:12
demo ajax
<?php
// MYSQL Connect here
// mysql_connect('...........');
$id = (isset($_REQUEST['id'])) ? intval($_REQUEST['id']) : 0;
if ($id) {
// Mysql query here
// $result = mysql_query("SELECT * FROM .........");
-- Cập nhật trạng thái phiếu mượn
CREATE DEFINER = CURRENT_USER TRIGGER `LoanDetails_AFTER_INSERT`
AFTER INSERT ON `LoanDetails` FOR EACH ROW
BEGIN
DECLARE _return_num INT;
SELECT COUNT(is_return) INTO _return_num FROM LoanDetails WHERE loan_id = NEW.loan_id AND is_return = 1;
IF _return_num = (SELECT COUNT(*) FROM LoanDetails WHERE loan_id = NEW.loan_id) THEN
UPDATE Loans SET is_return = 1 WHERE loan_id = NEW.loan_id;
END IF;
var RTBkit = require('../build/x86_64/bin/rtb.node');
var services = require('../build/x86_64/bin/services.node');
var zookeeperUri = "localhost:2181"; //must point to same Zookeeper as routers
var services = new services.ServiceProxies();
services.bootstrap('bootstrap.json');
var agent = new RTBkit.BiddingAgent('myAgent', services);