Skip to content

Instantly share code, notes, and snippets.

View punmechanic's full-sized avatar

Dan punmechanic

View GitHub Profile
@punmechanic
punmechanic / playground.rs
Created April 27, 2017 13:35 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::collections::{HashMap, VecDeque};
use std::collections::hash_map::Entry;
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
struct EntityId(usize);
enum Component {
}
<div class="col-lg-2 text-center" style="margin-top: 57px;">
@if (Model.ShowPushOptions)
{
<div style="display: inline; margin-left: 10px;">
@if (needsAction && !string.IsNullOrWhiteSpace(Model.LeftEntity))
{
<button id="pushToRight" class="btn btn-danger">Push <i class="glyphicon glyphicon-arrow-right"></i></button>
<br/>
}
@punmechanic
punmechanic / holyshit.js
Last active November 23, 2015 13:28 — forked from Vannevelj/holyshit.js
var regex = /\[([^\.]*?)\.?([^\.\]]*)\]/g;
var input = "123 [VALUE] abc [234.VALUE] def [123.NONONO] xyz";
function getReplacement(firstGroup, secondGroup) {
if (firstGroup && secondGroup == 'VALUE') {
return Promise.resolve('XXX');
}
if (!firstGroup && secondGroup == 'VALUE') {
return Promise.resolve('YYY');
function doReplaceAsync() {
return myAsyncFunc()
.then(function(character) {
return input.replace(/a/g, character);
});
}
function myAsyncFunc() {
return new Promise(resolve => {
for(let i = 0; i < 1000000; i++) {
@punmechanic
punmechanic / NullConditionalOperator.md
Created September 4, 2015 13:18 — forked from Nasicus/NullConditionalOperator.md
Null conditional operator: Check value for true (boolean check)

I just want to know what you guys think of the following code part and if you think it's readable or if you'd do it differentely.

Let's assume we have this class:

public class Foo
{
  public bool IsFooBar { get; set; }
}

An now we want to check for IsFooBar, but are not sure if our instance of Foo is null: