Skip to content

Instantly share code, notes, and snippets.

View ichadhr's full-sized avatar
Focusing

Chad ichadhr

Focusing
View GitHub Profile
@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 / 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 / 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 / UnknownSource.md
Last active October 7, 2019 15:40
OS X #UnknownSource

enabled

sudo spctl --master-enable

disabled

sudo spctl --master-disable

@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 / 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 / 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
```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
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
@ichadhr
ichadhr / PercentRounder.cs
Created October 23, 2019 07:24 — forked from dochoffiday/PercentRounder.cs
Uses the "Largest Remainder Method" to ensure rounded percentages add up to their correct total
using System;
using System.Collections.Generic;
using System.Linq;
public class PercentRounder
{
public class PercentInfo
{
public int Index;
public int Percent;