Skip to content

Instantly share code, notes, and snippets.

@DCCoder90
DCCoder90 / AddressPOCO.cs
Created February 26, 2018 17:22
A quick and dirty address validator using Google's Geocoding API. Could be easily expanded upon.
using System;
using System.Collections.Generic;
using System.Text;
namespace Validation
{
public class AddressComponent {
public string long_name { get; set; }
public string short_name { get; set; }
public List<string> types { get; set; }
@DCCoder90
DCCoder90 / Extensions.cs
Created January 18, 2018 04:48
A few extension methods for rounding
public static class Extensions{
/**
* Rounds the supplied number to the nearest multiple of the parameter
* @param this int The number to round
* @param int The multiple to use
* @return int
* @static
* @extension
*/
@DCCoder90
DCCoder90 / TerrainMath.cs
Created January 18, 2018 04:47
A collection of helpers for Terrain math with Unity
public static class TerrainMath{
/**
* Gets the XBase and width based on bounds input
* @param portalBounds The bounds of the Box collider to use
* @param terrainBounds The bounds of the terrain collider to use
* @return Vector2 Where X is the XBase and Y is the Width
* @static
*/
public static Vector2 GetXBaseAndWidth(Bounds portalBounds, Bounds terrainBounds){
@DCCoder90
DCCoder90 / mysqlBackup.sh
Created January 12, 2018 14:43
Bash script to backup all databases
#!/bin/bash
mysqldump -u root -p[PASSWORD] --all-databases | gzip > /PATH/TO/STORE/BACKUP/mysqldb_`date +%F`.sql.gz
@DCCoder90
DCCoder90 / Readme.txt
Last active March 22, 2018 16:07
A small, quick, and simple method of verify fields in a form.
Name: restrictInput
Signature: restrictInput(string type, event keypress);
Description: Restricts input to fields to specified values
Usage: $("#myfieldID").keydown(function(e)){
restrictInput("alpha",e);
};
Types:
alphanumeric - All letters and numbers
@DCCoder90
DCCoder90 / ForceNumeric.js
Created December 21, 2017 15:04
Forces only numeric input on selected field
$("selector").keydown(function (e) {
// backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Ctrl+A, Command+A
(e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) ||
// home, end, left, right, down, up
(e.keyCode >= 35 && e.keyCode <= 40)) {
return;
}
@DCCoder90
DCCoder90 / slackreport.js
Created November 30, 2017 14:58
Report youtrack changes to slack with duedate and approval
// Thanks to Michael Rush for the original version of this rule (https://software-development.dfstudio.com/youtracks-new-javascript-workflows-make-slack-integration-a-breeze-d3275605d565)
// IMPORTANT: Use a valid Incoming Webhook from Slack. To get one, go to https://my.slack.com/services/new/incoming-webhook/
var SLACK_WEBHOOK_URL = 'WEBHOOKURL';
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var http = require('@jetbrains/youtrack-scripting-api/http');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
@DCCoder90
DCCoder90 / Imager.cs
Created November 24, 2017 23:45
Part of a larger project. This section temporarily maps a network drive.
public class Imager : IDisposable{
private string _persist = "NO";
private Process _networkMap;
public void Dispose()
{
_networkMap.Close();
}
@DCCoder90
DCCoder90 / IsPrime.cs
Created November 24, 2017 15:50
Quick and dirty litter method to determine if a number is prime. Still has some issues that need to be worked out for int vs ulong
public static bool CalcIsPrime(dynamic number,out dynamic failure)
{
failure = 0;
if (number == 1) return false;
if (number == 2) return true;
if (number % 2 == 0) return false;
for (dynamic i = 2; i < (number/2); i++)
{
@DCCoder90
DCCoder90 / jqueryselectchange.js
Last active November 21, 2017 20:32
jQuery Select change snippets
$(document).ready(function(){
//For static content
$('#selectID').change(function(){
//Do stuff!
});
//For dynamically loaded content:
$(document).on('change','#selectID',function(){
//Do stuff!
});