Skip to content

Instantly share code, notes, and snippets.

View jasonknight's full-sized avatar

Jason Martin jasonknight

View GitHub Profile
@jasonknight
jasonknight / foobar.rb
Last active July 29, 2019 14:48
Trilogy Challenge: FooBar (FizzBuzz)
tests = [
{
:data => 1,
:expect => 1
},
{
:data => 2,
:expect => 2
},
{
@jasonknight
jasonknight / blur_1_2_3.rb
Last active July 29, 2019 18:06
Trilogy Challenge: Blur Image
class Image
def initialize(data)
@data = data
end
def get_image()
return @data.collect {|row| row.join("") }.join("\n")
end
def blur(dist=1)
new_data = @data.map do |r|
r.map do |c|
@jasonknight
jasonknight / linked_list_stack.rb
Last active July 31, 2019 21:29
Reversing a linked list with a stack
class Node
attr_accessor :value,:next_node
def initialize(val,nxt)
@value = val
@next_node = nxt
end
end
class Stack
attr_accessor :data
def initialize(d=nil)
@jasonknight
jasonknight / Introduction
Created November 3, 2019 22:43
0_Introduction.md
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>0_Introduction.md</title>
<link rel="stylesheet" href="https://stackedit.io/style.css" />
</head>
var users = [
{
role: 'admin',
email: 'fakeadmin1@email.com'
},
{
role: 'user',
email: 'fake2@email.com'
},
{
var users = [
{
role: 'admin',
email: 'fakeadmin1@email.com'
},
{
role: 'user',
email: 'fake2@email.com'
},
{
var user_data = {
admin_users: [
{
role: 'admin',
email: 'fakeadmin1@email.com'
},
{
role: 'admin',
email: 'fakeadmin2@email.com'
},
function renderPost(post) {
// some rendering logic
if ( getAdminEmails(users).indexOf(current_user.email) != -1 ) {
renderAdminControls(post);
}
}
$.getJSON('/posts',function (posts) {
posts.forEach( function (post) {
renderPost(post);
});
@jasonknight
jasonknight / IniLoader.cs
Last active April 1, 2020 21:57
C# Ini File Loader for Unity3d
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
public class IniLoader {
public string data;
public int position;
public void load(string path) {
program simple
implicit none
real a
real b
write(*,fmt='(a)',advance='no') 'Set a to: '
read*, a
write(*,fmt='(a)',advance='no') 'Set b to: '
read*, b
write(*,*) 'sq(a)=',sq(a),'sq(b)=',sq(b)
write(*,*) 'average(a,b)=',average(a,b)