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 / 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 / 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 / spellcheck.php
Created March 28, 2011 03:56
google spell check api
<?php
header("Content-Type: text/xml; charset=utf-8");
$url="https://www.google.com/tbproxy/spell?lang=en";
$text = urldecode("mystary");
$body = '<!--?xml version="1.0" encoding="utf-8" ?-->';
@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 / urlencode.m
Created March 18, 2012 12:16
URL Encode
@implementation NSString (url)
-(NSString *)urlEncodedString {
return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8) autorelease];
}
-(NSString *)urlDecodedString {
return [self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
@end
@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 / androidoffline.html
Created April 5, 2011 14:00
Offline link for android
<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;"><b>Update :- Honeycomb (3.0) and Latest Gingerbread (2.3.3) links updated</b></span><br>
<br>
<br>
<h1>How to install Android SDK without internet connection ? </h1><br>
I searched all over the internet and found no posts like this, hence I'm making one hoping it would be helpful for a lot of people.<br>
<br>
<b>The magic URL is </b>- <a href="http://dl-ssl.google.com/android/repository/repository.xml">http://dl-ssl.google.com/android/repository/repository.xml</a><br>
That is the XML file from which the URL for downloading the SDK packages are obtained.<br>
<br>
For e.g. if you want to download Mac version of Android SDK for version 2.0, you could look up that XML file. You will find a block under tag SDK 2.0 like this<br>
@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))