Skip to content

Instantly share code, notes, and snippets.

View niczak's full-sized avatar

Nicholas Kreidberg niczak

View GitHub Profile
niczak / gist:5470218
Last active April 12, 2021 08:22
Check file extension w/ JavaScript
View gist:5470218
function checkFile(file) {
var extension = file.substr((file.lastIndexOf('.') +1));
if (!/(pdf|zip|doc)$/ig.test(extension)) {
alert("Invalid file type: "+extension+". Please use DOC, PDF or Zip.");
niczak / gist:2501891
Created April 26, 2012 18:48
PHP Encrypt/Decrypt Class
View gist:2501891
class Encryption {
var $skey = "yourSecretKey"; // change this
public function safe_b64encode($string) {
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
return $data;
niczak / ExplorerHotKey.ahk
Created September 17, 2019 16:05
Very handy if you want to use a different file manager and have used Win+E for over a decade to launch Explorer.
View ExplorerHotKey.ahk
Run C:\Program Files (x86)\XYplorer\XYplorer.exe
niczak / gist:843202
Created February 25, 2011 00:37
TextMate commands to escape/unescape quotes.
View gist:843202
#!/usr/bin/env ruby
/* Thanks to @TextMateUser for help with this. */
/* Escape quotes */
puts STDIN.readlines.collect{|line| line.gsub('"','\\"')}
/* Remove escaping */
puts STDIN.readlines.collect{|line| line.gsub('\\"','"')}
niczak / gist:2003485
Created March 8, 2012 21:14
PHP/SOAP and Microsoft Exchange
View gist:2003485
Proof of concept testing to see if we can get
PHP/SOAP talking to EWS. Thanks to Thomas Rabaix
for his documentation on NTLM auth in SOAP and to
Erik Cederstrand for his article on SOAP/Exchange.
niczak / gist:5716548
Created June 5, 2013 19:31
UpSert Logic for Eloquent ORM
View gist:5716548
// search model for matching key
$record = FormDB::find('');
if($record) {
// record exists, update data
$record->text = "Updated";
} else {
niczak / 020_add_android_permissions.js
Created June 28, 2017 15:25 — forked from tomysmile/020_add_android_permissions.js
Add permissions to AndroidManifest.xml with cordova hook for Ionic 2
View 020_add_android_permissions.js
This script uses as a cordova hook and provides ability to add android permissions to AndroidManifest.xml on the fly. It also
checks and computes which of provided permissions are already added and didn't rewrite AndroidManifest.xml if no permissions provided.
Executes only for android platform.
- node 4.2+
- npm modules: lodash, xml2js
Distributed under the MIT license.
View DOSKEY.cmd
@echo off
DOSKEY clear=cls
DOSKEY ls=dir
niczak / template.html
Last active October 20, 2016 15:44
Barebones Bootstrap
View template.html
<!DOCTYPE html>
<html lang="en">
<!-- Meta yo -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Boostrap Page</title>
View getAccurateCurrentPosition.js
navigator.geolocation.getAccurateCurrentPosition = function (geolocationSuccess, geolocationError, geoprogress, options) {
var lastCheckedPosition,
locationEventCount = 0,
options = options || {};
var checkLocation = function (position) {
lastCheckedPosition = position;