Skip to content

Instantly share code, notes, and snippets.

Ernest Mallett DCCoder90

Block or report user

Report or block DCCoder90

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@DCCoder90
DCCoder90 / Vector3SerializationSurrogate.cs
Created Sep 4, 2017
A serialization surrogate to allow the serialization of Vector3's with Unity
View Vector3SerializationSurrogate.cs
using UnityEngine;
using System.Runtime.Serialization;
public class Vector3SerializationSurrogate : ISerializationSurrogate {
// Method called to serialize a Vector3 object
public void GetObjectData(System.Object obj, SerializationInfo info, StreamingContext context) {
Vector3 v3 = (Vector3)obj;
info.AddValue("x", v3.x);
@DCCoder90
DCCoder90 / Hash.cs
Created Sep 15, 2017
Create MD5 hash from a string
View Hash.cs
using System;
using System.Text;
using System.Security.Cryptography;
static public string GetMd5Sum(string str){
Encoder enc = System.Text.Encoding.Unicode.GetEncoder();
byte[] unicodeText = new byte[str.Length * 2];
enc.GetBytes(str.ToCharArray(), 0, str.Length, unicodeText, 0, true);
@DCCoder90
DCCoder90 / StripTags.cs
Created Sep 17, 2017
Static Class to assist in stripping HTML tags from strings or Char arrays
View StripTags.cs
using System;
using System.Text.RegularExpressions;
/// <summary>
/// Methods to remove HTML from strings.
/// </summary>
public static class StripTags
{
/// <summary>
/// Remove HTML from string with Regex.
@DCCoder90
DCCoder90 / jqueryselectchange.js
Last active Nov 21, 2017
jQuery Select change snippets
View jqueryselectchange.js
$(document).ready(function(){
//For static content
$('#selectID').change(function(){
//Do stuff!
});
//For dynamically loaded content:
$(document).on('change','#selectID',function(){
//Do stuff!
});
@DCCoder90
DCCoder90 / IsPrime.cs
Created Nov 24, 2017
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
View IsPrime.cs
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 / Imager.cs
Created Nov 24, 2017
Part of a larger project. This section temporarily maps a network drive.
View Imager.cs
public class Imager : IDisposable{
private string _persist = "NO";
private Process _networkMap;
public void Dispose()
{
_networkMap.Close();
}
@DCCoder90
DCCoder90 / slackreport.js
Created Nov 30, 2017
Report youtrack changes to slack with duedate and approval
View slackreport.js
// 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 / ForceNumeric.js
Created Dec 21, 2017
Forces only numeric input on selected field
View ForceNumeric.js
$("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 / Readme.txt
Last active Mar 22, 2018
A small, quick, and simple method of verify fields in a form.
View Readme.txt
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 / mysqlBackup.sh
Created Jan 12, 2018
Bash script to backup all databases
View mysqlBackup.sh
#!/bin/bash
mysqldump -u root -p[PASSWORD] --all-databases | gzip > /PATH/TO/STORE/BACKUP/mysqldb_`date +%F`.sql.gz
You can’t perform that action at this time.