Skip to content

Instantly share code, notes, and snippets.

View niczak's full-sized avatar

Nicholas Kreidberg niczak

  • Exacta Systems
  • Minneapolis, MN
  • X @niczak
View GitHub Profile
@niczak
niczak / gist:5470218
Last active April 12, 2021 08:22
Check file extension w/ JavaScript
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.");
$("#file").val("");
}
}
@niczak
niczak / gist:2501891
Created April 26, 2012 18:48
PHP Encrypt/Decrypt Class
<?php
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
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.
*#e::
Run C:\Program Files (x86)\XYplorer\XYplorer.exe
return
@niczak
niczak / gist:843202
Created February 25, 2011 00:37
TextMate commands to escape/unescape quotes.
#!/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
niczak / gist:2003485
Created March 8, 2012 21:14
PHP/SOAP and Microsoft Exchange
<?php
/*
test.php
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
niczak / gist:5716548
Created June 5, 2013 19:31
UpSert Logic for Eloquent ORM
<?php
// search model for matching key
$record = FormDB::find('blah@blah.com');
if($record) {
// record exists, update data
$record->text = "Updated";
$record->save();
} else {
@niczak
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
/*
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.
Prerequirements:
- node 4.2+
- npm modules: lodash, xml2js
Distributed under the MIT license.
@echo off
DOSKEY clear=cls
DOSKEY ls=dir
@niczak
niczak / template.html
Last active October 20, 2016 15:44
Barebones Bootstrap
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 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>
navigator.geolocation.getAccurateCurrentPosition = function (geolocationSuccess, geolocationError, geoprogress, options) {
var lastCheckedPosition,
locationEventCount = 0,
watchID,
timerID;
options = options || {};
var checkLocation = function (position) {
lastCheckedPosition = position;