Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
This file has been truncated, but you can view the full file.
aa
aah
aahed
aahing
aahs
aal
aalii
aaliis
aals
[
{ "type": "Fire", "icon": "fa-fire"},
{ "type": "Ice", "icon": "fa-cubes"},
{ "type": "Water", "icon": "fa-tint"},
{ "type": "Lightning", "icon": "fa-bolt"},
{ "type": "Gas", "icon": "fa-crosshairs"},
{ "type": "Poison", "icon": "fa-flask"},
{ "type": "Death", "icon": "fa-hotel"},
{ "type": "Undead", "icon": "fa-blind"},
{ "type": "Love", "icon": "fa-heart"},
@primaryobjects
primaryobjects / anagram.js
Last active September 14, 2016 15:08
Detect two words as an anagram.
//
// [2016-09-14] [2016-09-12] Challenge #283 [Easy] Anagram Detector
// https://www.reddit.com/r/dailyprogrammer/comments/52enht/20160912_challenge_283_easy_anagram_detector/
// Demo: http://primaryobjects.github.io/anagram/
// Kory Becker http://primaryobjects.com
//
export var AnagramManager = {
isAnagram: function(word1, word2) {
var result = false;
@primaryobjects
primaryobjects / JsonCamelCaseResult.cs
Created September 9, 2016 14:38
Serialize .NET objects as camelCase JSON.
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace System.Web.Mvc
{
public class JsonCamelCaseResult : ActionResult
{
public JsonCamelCaseResult()
{
@primaryobjects
primaryobjects / json2csharp.txt
Last active March 25, 2024 07:14
Neat trick to convert JSON to a C# class in Visual Studio.
1. Copy some JSON to your clipboard. Need some JSON? Here you go http://goo.gl/mWZSEL
2. In Visual Studio, right-click your project and select Add->Class.
3. Highlight the following code in your class:
class Class1
{
}
4. From the top menu, select Edit->Paste Special->Paste JSON as Classes.
5. Rename "Rootobject" to your desired class name. Done!
@primaryobjects
primaryobjects / react.html
Created September 8, 2016 14:15
Simplest example of ReactJs.
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js"></script>
</head>
<body>
<div id="container"></div>
</body>
</html>
@primaryobjects
primaryobjects / aa-readme.txt
Created September 7, 2016 18:44
3 examples of creating a simple "counter" app, demonstrated with React vs Angular vs jQuery.
Below, are 3 examples of creating a simple "counter" app, demonstrated with React vs Angular vs jQuery.
jQuery seems to be the simplest. Then again, this is a really simple app, and more complicated solutions
might be better suited towards frameworks like Angular and React.
jQuery "Counter" Example
https://jsbin.com/hazevidebu/edit?html,js,output
Angular "Counter" Example
https://jsbin.com/keyunasova/edit?html,js,output
@primaryobjects
primaryobjects / dank.js
Last active September 4, 2016 20:58
[2016-08-31] Challenge #281 [Intermediate] Dank usernames
//
// [2016-08-31] Challenge #281 [Intermediate] Dank usernames
// https://www.reddit.com/r/dailyprogrammer/comments/50hbtp/20160831_challenge_281_intermediate_dank_usernames/
// Demo: http://primaryobjects.github.io/dank/
// Kory Becker http://primaryobjects.com
//
// Load a word list and return an array of words, split upon the separator character(s).
function initialize(wordsFilePath, separator, callback) {
$.get(wordsFilePath, function(data) {
@primaryobjects
primaryobjects / bases.js
Last active September 4, 2016 00:45
[2016-08-29] Challenge #281 [Easy] Something about bases
//
// [2016-08-29] Challenge #281 [Easy] Something about bases
// https://www.reddit.com/r/dailyprogrammer/comments/504rdh/20160829_challenge_281_easy_something_about_bases/
// Demo: https://jsfiddle.net/8a34dphv/2/
// Kory Becker http://primaryobjects.com
//
// Convert a hex string into an array of decimal values.
function toNumArray(str) {
// Break value into characters.
@primaryobjects
primaryobjects / remove.txt
Created August 31, 2016 15:49
Remove a field from array element in MongoDb.
/* Find all documents containing "TargetField" in the array property "PreviousVersion", and remove the field "TargetField" from each one. */
db.coll.find({ "PreviousVersions.SomeObject.TargetField": { $exists: true }}).forEach(function(doc) {
var arr = doc.PreviousVersions;
for (var i = 0; i < arr.length; i++) {
delete arr[i].SomeObject.TargetField;
}
db.coll.save(doc);
});