Skip to content

Instantly share code, notes, and snippets.

View servel333's full-sized avatar

Nathaniel Perry servel333

View GitHub Profile
@servel333
servel333 / signtool.rb
Created September 20, 2013 19:45
A Ruby wrapper around signtool.exe in order to determine if a Windows file is digitally signed.
def require_signature(file)
abort file+' is not signed!' if !SignTool.is_signed file
end
def warn_if_not_signed(file)
puts '---- WARNING ---- '+file+' is not signed!' if !SignTool.is_signed file
end
class SignTool
@servel333
servel333 / wget.rb
Last active July 30, 2022 14:26
Basic Ruby implementation of wget to fetch a file from the internet.
def wget(url,file)
require 'net/http'
require 'uri'
if (!file)
file = File.basename(url)
end
url = URI.parse(url)
Net::HTTP.start(url.host) do |http|
@servel333
servel333 / make-npp-workspace.rb
Created September 20, 2013 19:39
Small Ruby script to generate a Notepad++ workspace from a path recursively.
# this.rb c:/path/to/scan > npp.workspace.xml
def puts(*args)
Kernel.puts *args
end
def scan_path(parent, indent='')
paths = Dir.glob(File.join(parent, '*'))
paths.select{ |path| !File.directory? path }.sort.each do |file|
@servel333
servel333 / $Array.js
Last active December 23, 2015 13:19
A method of extending the Array class without polluting the global namespace.
// http://perfectionkills.com/how-ecmascript-5-still-does-not-allow-to-subclass-an-array/
(function(window, undefined) {
"use strict";
var _extend = function() {
var a = [ ];
args = Array.prototype.slice.call(arguments);
a.push.apply(a, args);
@servel333
servel333 / applyDirect.js
Created September 20, 2013 17:33
A hacky alternative to function.apply and function.call in cases where those will not work.
(function(window, undefined) {
"use strict";
// @function func.apply( thisArg [, argsArray ] )
// @function func.call ( thisArg [, arg1 [, arg2 [, ...] ] ] )
var _applyIndirect = function(func, thisArg, argsArray) {
Function.prototype.apply.call(func, thisArg, argsArray);
};
@servel333
servel333 / JsUtils.js
Created September 20, 2013 17:14
A collection of simple JavaScript utilities.
////////////////////////////////////////////////////////////////////////////////
// Type utils
var is_object = function(o) { return o !== null && typeof o === 'object'; };
var is_number = function(o) { return !isNaN(parseFloat(o)) && isFinite(o); };
var is_string = function(o) { return typeof o === 'string'; };
var is_regexp = function(o) { return Object.prototype.toString.call( o ) === '[object RegExp]'; };
var is_regexp_duck = function(o) { return !!(o && o.test && o.exec && (o.ignoreCase || o.ignoreCase === false)); };
var get_internal_type = function(o) { return Object.prototype.toString.call(o).slice(8, -1); };