Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Bytes Crafter BytesCrafter

🏠
Working from home
View GitHub Profile
View gource-commands.txt
################################
gource commands
################################
# basic command for big and long projects
gource --max-user-speed 500 --seconds-per-day 0.05 --file-idle-time 10 -e 0.005 -f --max-files 300 --hide-files
# some easy to understand commands
# for output file
--output-ppm-stream ~/ppm/ppm-kohana
View gist:4e8aecf5480ad04be61c83bf8d97ea58
using Newtonsoft.Json;
using PasaBuy.App.Controllers.Notice;
using PasaBuy.App.Models.Onboarding;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
namespace XamarinNet
{
View WordPress DB Hook
function dbhook_activate() {
global $wpdb;
// #region CREATING TABLE FOR Clusters
$usn_cluster_tab = USN_CLUSTER_TAB;
if($wpdb->get_var( "SHOW TABLES LIKE '$usn_cluster_tab'" ) != $usn_cluster_tab) {
$sql = "CREATE TABLE `".$usn_cluster_tab."` (";
$sql .= "`ID` bigint(20) NOT NULL AUTO_INCREMENT, ";
$sql .= "`cluster_name` varchar(120) NOT NULL, ";
$sql .= "`cluster_info` varchar(255) NOT NULL, ";
View Xamarin-RestAPI.cs
using System.Net.Http;
using System.Net.Http.Headers;
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace BytesCrafter.Xamarin
{
@BytesCrafter
BytesCrafter / nodejs-cpu-percent.js
Created Apr 28, 2020
Convert the output of os.cpus() in Node.js to percentage
View nodejs-cpu-percent.js
// According to the http://nodejs.org/docs/latest/api/os.html#os_os_cpus, times is
// an object containing the number of CPU ticks spent in: user, nice, sys, idle, and irq
// So you should just be able to sum the times and calculate the percentage, like below:
var cpus = os.cpus();
for(var i = 0, len = cpus.length; i < len; i++) {
console.log("CPU %s:", i);
var cpu = cpus[i], total = 0;