Skip to content

Instantly share code, notes, and snippets.

View satbirdd's full-sized avatar

liu lei satbirdd

  • Changsha, China
View GitHub Profile
@satbirdd
satbirdd / gist:6945775
Last active December 25, 2015 08:19
sendmessage
var index = 1;
function sendMessage() {
var room_name = "中华网军事战略群";
var message = "这是我发送的第 [" + index + "] 条信息";
index ++;
$("#room-" + room_name).val(message);
setTimeout(function(){
$("#room-" + room_name).trigger("input");
$("button[type=submit]").click();
}, 0);
// do_sync();
// do_async();
// async_mode();
// function: setTimeout
// sync
function do_sync() {
# !/bin/bash
# postgresql apt-get repository
# sudo touch /etc/apt/sources.list.d/pgdg.list
# echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# redis apt-get repository
echo "deb http://archive.ubuntu.com/ubuntu precise main universe" | sudo tee -a /etc/apt/sources.list
#!/bin/bash
cd /vagrant
bundle
bundle exec rake db:create RAILS_ENV=production
bundle exec rake db:migrate RAILS_ENV=production
bundle exec sidekiq
rails s -p 5000 -e production
function get_async_data(url, callback) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (4 === xmlhttp.readyState && 200 === xmlhttp.status) {
// console.log(xmlhttp.response);
callback(JSON.parse(xmlhttp.response));
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send()
@satbirdd
satbirdd / setup_work.sh
Created June 20, 2014 01:34
ubuntu(gnome) teminate setup bash script
#!/bin/bash
gnome-terminal\
--tab\
--title="Neil"\
--working-directory="/home/robin/works/neil-rails-app"\
-e "bash -c 'rails s -p 4000'"\
--tab\
--title="Front"\
--working-directory="/home/robin/works/neil-rails-app/vendor/frontend"\
-e "bash -c 'PORT=5000 grunt serve:proxy'"\
<div style='position: relative; overflow: hidden;'>
<div style="width:130px; height: 130px; cursor: pointer;
background-size: contain;
background-repeat: no-repeat;
background-position: 50% 50%;"
class='image' />
</div>
<input type='file' style="position: absolute; top: 0; left: 0; margin: 0; opacity: 0; -ms-filter: 'alpha(opacity=0)'; font-size: 130px; overflow: hidden; width: 130px; height: 130px; direction: ltr; cursor: pointer;">
上传最好是本人的个人照</br>
头像支持图像格式:jpeg, png,git,大小不超过4M<br>
@satbirdd
satbirdd / js_id.js
Created September 24, 2014 13:57
generate id for javascript class
function A () {
this.generateId();
}
A.prototype.generateId = (function () {
var count = 0;
return function () {
count ++;
this.id = count;
@satbirdd
satbirdd / Ubuntu12.04-g++4.8
Created April 23, 2016 05:41 — forked from akoluthic/Ubuntu12.04-g++4.8
Install g++ 4.8 on Ubuntu 12.04
*Add the toolchain/test PPA*
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
*If you ever want to update symlinks for a future version:*
sudo rm /usr/bin/g++
sudo ln -s /usr/bin/g++-4.XXX /usr/bin/g++
gnome-terminal\
--tab\
--title="Rails"\
--working-directory="/home/username/works/project"\
-e "bash -c 'rails s;bash'"\
#the gnome-terminal closes after the somecommand terminates, the reason being gnome-terminal not running the bash as it's default shell.
#To get the bash prompt($) after the command command completes, you need to trigger it back.