Skip to content

Instantly share code, notes, and snippets.

@nainglinaung
nainglinaung / Basic Gold Price Calculator
Created April 18, 2014 18:48
Calculation for Masses of Gold are different between International standard and Myanmar, we need own calculator for that and that's the example
# Declaration
mass = [];
def check_num num
raise(ArgumentError, "Put Numbers only") if /[[:alpha:]]/.match(num)
end
# Enter mass
puts "enter kyat, pyel, ywey with coma seperated value. 'x,y,z' "
input = gets
@nainglinaung
nainglinaung / gist:1a7f454e84d4990abd62
Last active August 29, 2015 14:18
The sum of number less than 1000 which is divisible by 3 or 5
console.log(Array.apply(null, Array(1000)).map((_, i)=>i+1).filter(v=> v%5==0||v%3==0).reduce((a,b)=>a+b));
var input = process.argv[2];
var DayDict = {'sun':6,'mon':15,'tue':8,'wed':17,'thu':19,'fri':21,'yar':12};
console.log((input in DayDict)? DayDict[input]*3-3:'invalid input');
var website = "http://shiroyukitranslations.com/lls-chapter-";
// <a href="http://shiroyukitranslations.com/long-live-summons/#tabs_desc_8329_4">Team</a>
var fs = require('fs');
var stream = fs.createWriteStream("my_file.txt");
stream.once('open', function(fd) {
for(i=1; i<465; i++) {
@nainglinaung
nainglinaung / aggrate.js
Created June 15, 2017 11:10
Change type in field
var devices = db.getCollection('devices').aggregate([
{ "$group" : {_id:"$something" } }
]);
var batch = devices._batch;
for(i=0; i<=batch.length; i++) {
if (batch[i]) {
if (batch[i]._id) {
if (typeof(batch[i]._id) == 'number') {
<?php
class Dog{
public function __call($_,Array $arguments)
{
echo $arguments[0];
}
}
@nainglinaung
nainglinaung / object-merger.js
Last active December 27, 2017 09:28
Javascript Object Merger with ES6
mergeObject: (obj1 = {}, obj2 = {}) => {
let ObjArray = [obj1,obj2];
let key1 = Object.keys(obj1);
let key2 = Object.keys(obj2);
let unionKeys = [...new Set([...key1 ,...key2])];
let ignore = new Set(['createdAt','updatedAt','updated_at','_id']);
let result = {};
let keysMap = new Map();
unionKeys = new Set([...unionKeys].filter(x => !ignore.has(x)));
@nainglinaung
nainglinaung / nginx-tuning.md
Created July 3, 2018 10:30 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@nainglinaung
nainglinaung / example.py
Created August 13, 2021 07:43
for testing
import requests
import json
url = "http://139.59.234.141:6000/beacon"
payload = json.dumps({
"timestamp": 1628151498,
"datetime": "05-Aug-2021 15:18:18",
"riderdome_device_id": "1423219059433",
"ride_id": 3,