Skip to content

Instantly share code, notes, and snippets.

View saturngod's full-sized avatar
🎯
Focusing

Htain Lin Shwe saturngod

🎯
Focusing
View GitHub Profile
public interface LoginStrategy {
public void login();
}
public class UsernamePasswordLogin implements LoginStrategy {
private String username;
private String password;
@saturngod
saturngod / php-fpm-tuning.sh
Created December 18, 2022 07:22
update worker base on system
#!/bin/bash
# Get the total system memory in MB
total_memory=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
# Calculate the amount of memory to use for PHP-FPM workers
memory_per_worker=$((total_memory / 8 / 1024))
# Get the number of CPU cores
cpu_cores=$(grep -c ^processor /proc/cpuinfo)
@saturngod
saturngod / animated_add_close.dart
Created June 19, 2022 03:36
Animation Add Close
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
@saturngod
saturngod / BunnyVOD.php
Last active March 22, 2023 21:08 — forked from ToshY/BunnyVOD.php
BunnyCDN VOD HLS Token Authentication V2 with directory tokens
<?php
function sign_bcdn_url($url, $securityKey, $expiration_time = 3600, $user_ip = NULL, $is_directory_token = false, $path_allowed = NULL, $countries_allowed = NULL, $countries_blocked = NULL)
{
if(!is_null($countries_allowed))
{
$url .= (parse_url($url, PHP_URL_QUERY) == "") ? "?" : "&";
$url .= "token_countries={$countries_allowed}";
}
if(!is_null($countries_blocked))
@saturngod
saturngod / shouldupdate.kt
Created July 24, 2019 03:19
Check version compare to update or not
fun shouldUpgrade(server_version: String, app_version: String): Boolean {
if (server_version == app_version) {
return false
}
val versions = server_version.split(".")
val apps = app_version.split(".")
@saturngod
saturngod / binhex.kt
Last active April 6, 2018 06:18
bin2hex and hex2bin
//bin2hex and hex2bin with Kotlin
import javax.xml.bind.DatatypeConverter
fun bin2hex(byteArray: ByteArray): String {
return DatatypeConverter.printHexBinary(byteArray);
}
fun hex2bin(binary: String): ByteArray {
return DatatypeConverter.parseHexBinary(binary)
@saturngod
saturngod / en2mmno.kt
Created November 28, 2017 10:48
English Number to Myanmar Number
/**
* Created by saturngod on 28/11/17.
*/
fun main(args:Array<String>) {
var k = "49085678237896"
print(getMMNumber(k))
@saturngod
saturngod / bubblesort.mm
Last active August 29, 2015 14:03
Bubble Sort
NSMutableArray *res2 = [[NSMutableArray alloc] initWithArray:@[@2,@34,@452,@45,@234,@6,@3,@1,@343,@543,@23,@2,@34,@452,@45,@234,@6,@3,@1,@343,@543,@23,@2,@34,@452,@45,@234,@6,@3,@1,@343,@543,@23,@2,@34,@452,@45,@234,@6,@3,@1,@343,@543,@23]];
int passnum = res2.count -1 ;
BOOL exchange = YES;
NSDate *date = [NSDate date];
while (passnum >0 && exchange) {
exchange = false;
for (int i = 0 ; i < passnum ; i++)
@saturngod
saturngod / uibarbuttonwithimage.mm
Created September 12, 2013 12:13
uibarbutton item image
UIImage *chatImage = [UIImage imageNamed:@"08-chat.png"];
UIButton *chatButton = [UIButton buttonWithType:UIButtonTypeCustom];
[chatButton setBackgroundImage:chatImage forState:UIControlStateNormal];
[chatButton setTitle:@"Chat" forState:UIControlStateNormal];
chatButton.frame = (CGRect) {
.size.width = 100,
.size.height = 30,
};
@saturngod
saturngod / VerbalExpressions_Math.js
Created August 6, 2013 10:10
Testing VerbalExpressions
var tester = VerEx()
.then( "http" )
.maybe( "s" )
.then( "://" )
.maybe( "www." )
.anythingBut( " " );
// Create an example URL
var testMe = "This is testing. https://www.google.com is a URL. http://www.facebook.com also URL.";
var result = testMe.match(tester);