Skip to content

Instantly share code, notes, and snippets.

View SecretDeveloper's full-sized avatar
🎯
Focusing

Gary Kenneally SecretDeveloper

🎯
Focusing
View GitHub Profile
@SecretDeveloper
SecretDeveloper / SubSetSumSolution.cs
Last active September 25, 2015 07:28
.Net solution to the subset sum problem.
public class SubSetSolver
{
// Define other methods and classes here
public void Solve(string input)
{
List<int> seq = input.Split(',').Select(x => int.Parse(x)).ToList();
seq.Sort();
List<List<int>> combinations = new List<List<int>>(seq.Count *2);
@SecretDeveloper
SecretDeveloper / PHP badness
Last active September 27, 2015 04:07
PHP badness
<?php
$result = mysql_query('SELECT * FROM Customers');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
@SecretDeveloper
SecretDeveloper / Widget configuration injection.js
Last active August 29, 2015 14:04
Widget configuration injection
(function(root){
var widget = function(){
var self = this;
// configuration
var config = {
css:{
theme:'current'
@SecretDeveloper
SecretDeveloper / Widget code isolation.js
Last active August 29, 2015 14:04
Widget code isolation
var myVariable = "Some external value;"
(function(root){
var myVariable = "Some internal value;"
console.log(myVariable); // will be "Some internal value"
})(window);
console.log(myVariable); // will still be "Some external value"
@SecretDeveloper
SecretDeveloper / RE Builder for list comparison.cs
Last active August 29, 2015 14:04
Regular Expression Builder for filtering 2 list of terms - LINQpad version.
void Main()
{
string A = @"A New Hope
The Empire Strikes Back
Return of the Jedi
The Phantom Menace
Attack of the Clones
Revenge of the Sith";
@SecretDeveloper
SecretDeveloper / Safely loading JS libraries (jQuery).js
Last active August 29, 2015 14:04
Safely loading JS libraries (jQuery)
function loadScript(address, callback) {
var script_tag = document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src", address);
if (script_tag.readyState) {
script_tag.onreadystatechange = function () { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
callback();
}
};
@SecretDeveloper
SecretDeveloper / Greatest Common Denominator using Euclidian Algorithm
Created June 19, 2015 13:14
Greatest Common Denominator using Euclidian Algorithm
// Greatest Common Denominator using Euclidian Algorithm
int gcd(int a, int b)
{
return b==0 ? a : gcd(b, a % b);
}
@SecretDeveloper
SecretDeveloper / GenerateRandomString.cs
Last active September 11, 2015 10:42
Generate Random String
public static string GenerateRandomString(int length = 32)
{
if (length <= 0)
throw new ArgumentException("provided length must be greater than 0");
using (RNGCryptoServiceProvider cryptoProvider = new RNGCryptoServiceProvider())
{
var bytes = new byte[length];
cryptoProvider.GetNonZeroBytes(bytes);
@SecretDeveloper
SecretDeveloper / unsong.fs
Last active November 10, 2016 18:34
unsong.fs
// Create epub file from unsongbook.com and write to console.
open FSharp.Data
open System.Collections.Generic
type Chapter(title:string, body:string, url:string)=
member x.Title = title
member x.Body = body
member x.URL = url
let chapters = new List<Chapter>()
@SecretDeveloper
SecretDeveloper / ConvertVisioToPNG.vbs
Last active October 7, 2019 13:03
ConvertVisioToPNG.vbs
Option Explicit
'################################################
'This script is to export Visio and PUML files to PNG files
'################################################
Sub main()
Dim ArgCount, argumentPath, workItems, skipped, scriptdir
ArgCount = WScript.Arguments.Count