Skip to content

Instantly share code, notes, and snippets.

View ichadhr's full-sized avatar
Focusing

Chad ichadhr

Focusing
View GitHub Profile
function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
return true;
}
}
return false;
}
// sample
```php
$array=[
['day'=>'11','movements'=>'1'],
['day'=>'11','movements'=>'1'],
['day'=>'11','movements'=>'1'],
['day'=>'12','movements'=>'1'],
['day'=>'12','movements'=>'1'],
['day'=>'12','movements'=>'1']
];
foreach($array as $row){ // iterate all rows
@ichadhr
ichadhr / Sql Sorting Lat Long.md
Last active October 7, 2019 15:36
Geo latitude longtitude order

simple ordering lat long MySQL

SELECT
	*,
	6371 * ASIN(
		SQRT(
			POWER( SIN( ( '-8.637420' - sample.lat ) * pi( ) / 180 / 2 ), 2 ) + COS( '-8.637420' * pi( ) / 180 ) * COS( sample.lat * pi( ) / 180 ) * POWER( SIN( ( '115.253001' - sample.lng ) * pi( ) / 180 / 2 ), 2 ) 
		) 
	) AS distance 
FROM
@ichadhr
ichadhr / index.php
Last active October 7, 2019 15:37
PHP Get lat, long from address
// ------------------------------------------
// converts a string with a stret address
// into a couple of lat, long coordinates.
// ------------------------------------------
public function getLatLong($address){
if (!is_string($address))die("All Addresses must be passed as a string");
$_url = sprintf('http://maps.google.com/maps?output=js&q=%s',rawurlencode($address));
$_result = false;
if($_result = file_get_contents($_url)) {
if(strpos($_result,'errortips') > 1 || strpos($_result,'Did you mean:') !== false) return false;
@ichadhr
ichadhr / zues.xml
Last active October 7, 2019 15:41
Zeus modified theme for VS Code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Zeus</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@ichadhr
ichadhr / UnknownSource.md
Last active October 7, 2019 15:40
OS X #UnknownSource

enabled

sudo spctl --master-enable

disabled

sudo spctl --master-disable

@ichadhr
ichadhr / snip_list_numeric_filter.py
Created October 4, 2018 07:50
Remove empty and non numeric from list #python #list #numeric #filtering
# check a list for float type value
def checkListFloat(self, arList, isfloat = False) :
result = []
for _i in arList:
if self.checkFLoat(_i) :
result.append([int(float(_i))])
else :
res = re.sub('[^\d\.,]', '', _i)
if res :
result.append([res])
@ichadhr
ichadhr / snip-tabula.py
Last active October 7, 2019 15:52
Simple use tabula.jar with python #tabula #python
# running tabula
def tabula(jarfile, coordinate, pathFile) :
output = self.launchWithoutConsole('java', ['-jar', str(jarfile), '-p', 'all', '-a', str(coordinate), str(pathFile)])
return output
# Subprocess without console (PyInstaller)
def launchWithoutConsole(command, args):
@ichadhr
ichadhr / READ.md
Last active October 7, 2019 15:42
Automatic run as Administrator
  1. Open Local Security Policy Editor (on the Start screen type "secpol" and click it).
  2. From the menu on the left, expand "Local Policy".
  3. Under the expanded "Local Policy" heading, select "Security Options".
  4. On the panel on the right find "User Account Control: Run all administrators in Admin Approval Mode", open this setting and change the value to Disabled.

Policy Editor

@ichadhr
ichadhr / tld.sh
Last active October 7, 2019 15:43
Checking longest TLD
curl -s http://data.iana.org/TLD/tlds-alpha-by-domain.txt | tail -n+2 | wc -L