Skip to content

Instantly share code, notes, and snippets.

View musoftware's full-sized avatar
🌏
Working from home

Musoftware musoftware

🌏
Working from home
View GitHub Profile
@musoftware
musoftware / gist:f5700f96b7db37a97080bbb7e5faf9cc
Created November 9, 2020 22:54 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@musoftware
musoftware / base.php
Last active January 26, 2020 20:15
convert cusom base
<?php
function toBase($num, $b=62) {
$base='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$r = $num % $b ;
$res = $base[$r];
$q = floor($num/$b);
while ($q) {
$r = $q % $b;
$q =floor($q/$b);
$res = $base[$r].$res;
defaults delete com.apple.dt.Xcode
rm -rf $HOME/Library/Application Support/Developer/Shared/Xcode
rm -rf $HOME/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState
rm -rf $HOME/Library/Preferences/com.apple.dt.Xcode.*
@musoftware
musoftware / MySingleton.java
Created September 19, 2019 00:04
MySingleton
package me.amcapp.amc.Tasks;
import android.content.Context;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
/**
* Created by CHEA THAILY on 11/8/2017.
@musoftware
musoftware / IP.php
Last active May 16, 2019 04:14
Get real user IP USING PHP
<?php
function get_client_ip_server() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
@musoftware
musoftware / DelegateSample.cs
Last active February 28, 2019 16:30
DelegateSample
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelegateSample
{
class Program
{
@musoftware
musoftware / grequests.py
Created August 2, 2018 23:39
Get Multi Request
import grequests
urls = [
'https://graph.facebook.com/',
'https://graph.facebook.com/2',
]
rs = (grequests.get(u) for u in urls)
p = grequests.map(rs)
@musoftware
musoftware / file.py
Created August 2, 2018 23:16
Work With Request and Json
import requests
r = requests.get('https://github.com/timeline.json')
print(r.json()['message'])
@musoftware
musoftware / file.py
Created August 2, 2018 23:14
Open File
def file_get_contents(filename):
with open(filename) as f:
content = f.read()
f.close()
return content
@musoftware
musoftware / Extensions.cs
Created June 23, 2018 19:25
NameValueCollection to postData
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
public static class Extensions
{
public static string ToPostData(this NameValueCollection @this)