Skip to content

Instantly share code, notes, and snippets.

View vumanhcuongit's full-sized avatar

Cuong Vu vumanhcuongit

View GitHub Profile
@vumanhcuongit
vumanhcuongit / gist:afcdaf0476dfe5f16c6b
Last active August 29, 2015 14:20
Response retrieved from Superfeedr
{"status":
{"http":"Fetched (late) 200 86400 and parsed 0/1 entries",
"code":200,
"nextFetch":1430191514,
"lastFetch":1430191514,
"lastParse":1430105114,
"lastMaintenanceAt":1430105114,
"period":86400,
"feed":"http://techcrunch.com/tag/techlist/feed/"},
"title":"TechCrunch » techlist",
@vumanhcuongit
vumanhcuongit / interleave_array.rb
Last active August 29, 2015 14:12
Interleave Array
def interleave(a, b)
return [a, b].transpose.flatten if a.size == b.size
if a.size > b.size
b << nil
else
a << nil
end
[a, b].transpose.flatten.compact
@vumanhcuongit
vumanhcuongit / gist:d6080c16041cd9480e12
Last active August 29, 2015 14:06
neo4j cheat sheet
# Create Server Object
Server.create(os: 'Windows', ram: 8)
# Create Service Object
Service.create(type: 'HAD23W', service_id: 1532, ip: '192.168.1.1')
# Create Customer Object
Customer.create(name:'Cuong Vu', email:'[email protected]')
# One service belongs to One server
$('#grid').w2grid({
name: 'grid',
show: {
lineNumbers: true,
footer: true
},
recordsPerPage: 100,
columns: [
{ field: 'month_report', caption: 'Month', size: '10%', resizable: true, sortable: true },
{ field: 'account_short_name', caption: 'Short Name', size: '15%', resizable: true,
Hello world !
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':["imagechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
// Create and populate the data table.
var today_electricity_cost = <%= number_with_precision(Calc.today_avg_electricity_cost_of_lighting(@location), :precision => 2) %>
var sum_lamp_maint = <%= number_with_precision(Calc.sum_lamp_maint_saving_per_month(@location), :precision => 2) %>
var sum_total_savings = <%= number_with_precision(Calc.sum_total_savings_month(@location), :precision => 2) %>
var data = google.visualization.arrayToDataTable([
['Today', 'Average monthly electricity cost of lighting ($'+today_electricity_cost+')', 'Average monthly lamp maintenance cost ($'+sum_lamp_maint+')', 'Average monthly cost of ballast mainteance ($'+sum_total_savings+')'],
$('form#new_task').submit(function() {
$.ajax({
type: "POST",
url: $(this).attr('action'), //sumbits it to the given url of the form
data: {
data_1: value_1,
data_2: value_2
}, //input gui di
dataType: "HTML",
success(function(result){
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="jquery.masonry.min.js" type="text/javascript"></script>
<script src="jquery.infinitescroll.min.js" type="text/javascript"></script> // thu vien moi, luu y: xep dang sau masonry.min.js
<script type="text/Javascript">
$(document).ready(function () {
init();
});
function init() {
var $container = $('#container');
$container.imagesLoaded( function(){
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
},{scope:"user_photos"});