Skip to content

Instantly share code, notes, and snippets.

View LukeTully's full-sized avatar

Luke Tully LukeTully

View GitHub Profile
@LukeTully
LukeTully / repeating-contributers.html
Created June 19, 2019 02:58
Modify repeating output template
# In a custom plugin, you can put this in templates/scheming/display_snippets/{yournamehere}.html
# If you're using ckanext-scheming, you can set the display_snippet on your field to {yournamehere}.html
{%- set values = data[field.field_name] -%}
<ol> {%- for contributer in values -%}
# Access the keys of each field dict and print them as you please
<li>{{ contributer['name'] }}</li>
{%- endfor -%}
</ol>
@LukeTully
LukeTully / guessinggame.cpp
Created September 13, 2017 07:40
C++ basic guessing game
#include <iostream>
int divideAndConquer(int min, int max);
int main()
{
int current = 50, max = 100, prev = 0;
std::string next;
std::string posAns = "y";
std::string negAns = "n";
@LukeTully
LukeTully / mortage.vue
Created March 22, 2017 23:25
Basic Vue-based loan calculator
<template>
<div id="app-container">
<form>
<label for="principal">Principal</label>
<input type="number" name="principal" v-model="principal" />
<label for="rate">Rate</label>
<input type="text" name="rate" v-model="rate" />
</form>
<p>
Total Amount: {{totalAmount}}
@LukeTully
LukeTully / contrast.js
Created February 5, 2017 13:16
Basic implementation of static contrast manipulation in JavaScript
var canvas = document.getElementById("main-image-canvas");
var ctx = canvas.getContext('2d');
var imageSrc =
"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wgARCAJYAlgDASIAAhEBAxEB/8QAHAAAAgMBAQEBAAAAAAAAAAAAAgMAAQQFBgcI/8QAGAEBAQEBAQAAAAAAAAAAAAAAAAECAwT/2gAMAwEAAhADEAAAAfTLffLpmbACUSg4EKXaggqghqFCVA1dJKuiSpUkhJISrMCFRUuiS4SVC4dAwoVchZCSG1bQ/NTznmvqB8n6fbmgF8WVEuF3a92HmZYxLE21qwa9R7mB5qqlh0jcjK2G1huOpLLFjeguMnn19gpdeumFAXBIqqEtZLKoRDi6QhqEkhJIVJKlXCpISSi7qySoXKsoqhdgRdSkOCZDpikjXzMvJZNifHcm/F0tzGzGBrTu5+DM+3JuqIb3GpfmldQsTRl0lhkaYVmB2PrNMXWoLsl11Hod5dVEyvrquqn13n1pUZ6YsEIsYIEDTIKjRRdGIMkJUokkqSQqXCpcKl0SXQVQgauJV3CrI1UZETLr4OXT869fByK1pxcbnKM2haabSq1Ohh2Z8azac+npmnrDna0LWPbmUlCt/SVjcraEvqHPf2cvDWRyWWLmadX30Vq62KtYCzEUvQAgXAKohKGxSqsSVISpKlXCpdgwxKkhckLlQuURUkSXVhHydGW+4Whec9NwMVGOcrhXqQzBi812NzmOrrysVmQ85boMFlmgNQcaKG5
@LukeTully
LukeTully / package.json
Created December 10, 2016 11:55
Standard package.json - Quickstart on setting up a node server with frontend build tools
{
"name": "RENAME THE PROJECT",
"version": "0.0.1",
"description": "ADD DESCRIPTION",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
@LukeTully
LukeTully / gulpfile.js
Created December 10, 2016 11:45
Example gulpfile for standard framework agnostic building
const gulp = require('gulp');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const liveReload = require('gulp-livereload');
const sass = require('gulp-sass');
const babel = require('gulp-babel');
const sourceMaps = require('gulp-sourcemaps');
const ROOTPATHS = {
static: './static/',
@LukeTully
LukeTully / readme.md
Created December 10, 2016 02:56
Simplified instructions on how to host a git repo

How to setup and work with a remote git repo on your own server

Sites like Github and Bitbucket make it ridiculously easy to setup public and private remote repos, which might make a lot of sense for your team. Sometimes there is an added cost to this though, whether financially or simply introducing another third-party dependency into your project.

Setting up your own git repo is easy and allows you to host your versioning system on your own server.

Getting started on the remote server

We'll need to set up a dedicated user to manage the repos.

  1. su - // Enter super user
class Card {
constructor(suit, face, worth) {
this.suit = suit;
this.face = face;
this.worth = worth;
}
}
class CardDeck {
// String replacement with index constraints
function replaceBetween(startIndex, endIndex, search, replace, text) {
// Portion of text up until the section we want to search in
var firstChunk = text.slice(0, startIndex);
var lastChunk = (endIndex !== text.length - 1) ? text.slice(endIndex, text.length) : "";
// Create the string to search within
var searchableText = text.slice(startIndex, endIndex);
@LukeTully
LukeTully / quickSwap
Last active September 12, 2016 11:48
Example implementation of basic algorithm to reverse the characters of words in a sentence and return it as a string
var exampleString = "This is an example String";
var words = parseWords(exampleString);
var reversedWords = [];
var finishedString = '';
for(var i = 0; i < words.length; i++){
// Reverse each word and push it into the final list