Instantly share code, notes, and snippets.

View mavlink_common.lua
View addcommas.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
/**
* Turns the array into a sentence.
*
* @example
* {{ ['Stephen', 'Trevor' ] | AddCommas:'Customer' }}
*/
@Pipe({ name: 'AddCommas' })
export class AddCommasPipe implements PipeTransform {
View openpanzer-save.json
{"scenario":{"name":"Panzer-Verbaende Ostpreussen","maxTurns":17,"date":"1939-09-18T22:00:00.000Z","atmosferic":0,"latitude":2,"ground":0,"turnsPerDay":0,"dayTurn":0,"reinforcements":{},"map":{"rows":32,"cols":38,"map":[[{"unit":null,"airunit":null,"terrain":0,"road":0,"owner":-1,"flag":-1,"isDeployment":-1,"victorySide":-1,"name":"","isMoveSel":false,"isAttackSel":false},{"unit":null,"airunit":null,"terrain":0,"road":0,"owner":-1,"flag":-1,"isDeployment":-1,"victorySide":-1,"name":"","isMoveSel":false,"isAttackSel":false},{"unit":null,"airunit":null,"terrain":0,"road":0,"owner":-1,"flag":-1,"isDeployment":-1,"victorySide":-1,"name":"","isMoveSel":false,"isAttackSel":false},{"unit":null,"airunit":null,"terrain":0,"road":0,"owner":-1,"flag":-1,"isDeployment":-1,"victorySide":-1,"name":"","isMoveSel":false,"isAttackSel":false},{"unit":null,"airunit":null,"terrain":0,"road":0,"owner":-1,"flag":-1,"isDeployment":-1,"victorySide":-1,"name":"","isMoveSel":false,"isAttackSel":false},{"unit":null,"airunit":null,"terr
View url_shortner.py
"""
Scamming the coding interview
"""
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
memory_db = {}
def get_shorten_url(long_url, url_id):
View gist:4c245cbc5fd26bb76f5e61ef80c9e8d5
<?php
declare(strict_types = 1);
namespace drupol\phptree\Converter;
use drupol\phptree\Node\NodeInterface;
use drupol\phptree\Traverser\BreadthFirst;
use drupol\phptree\Traverser\TraverserInterface;
use Fhaculty\Graph\Graph as OriginalGraph;
View pytien.py
# sums a list of numbers
def f (p):
if not isinstance (p,list):
raise ValueError ("type error")
x, *xs = p
return x if xs == [] else x + f (xs)
View userdata
#!/bin/bash -xe
echo '{ "log-driver": "json-file", "log-opts": { "max-size": "20m", "max-file": "10" }}' > /etc/docker/daemon.json
systemctl restart docker
CA_CERTIFICATE_DIRECTORY=/etc/kubernetes/pki
CA_CERTIFICATE_FILE_PATH=$CA_CERTIFICATE_DIRECTORY/ca.crt
mkdir -p $CA_CERTIFICATE_DIRECTORY
echo "${aws_eks_cluster.cluster.certificate_authority.0.data}" | base64 -d > $CA_CERTIFICATE_FILE_PATH
INTERNAL_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)
View examsLess.csv
gender ethnicity parentEducation lunch testPrepCourse math reading writing
female group D some high school standard none 63 70 73
female group B some high school free/reduced none 54 56 62
female group E some college free/reduced none 73 82 78
male group D bachelor's degree standard none 53 49 44
female group E some college standard none 67 79 74
female group B high school standard completed 70 76 71
male group B some high school standard completed 62 70 66
female group C bachelor's degree standard none 48 65 60
female group C bachelor's degree free/reduced none 65 79 73
View cass_python
from cassandra.cluster import Cluster
cluster = Cluster(protocol_version = 3)
session = cluster.connect('killrvideo')
for val in session.execute("SELECT * FROM videos_by_tag"):
print(val[0])
print('{0:12} {1:40} {2:5}'.format('Tag', 'ID', 'Title'))
for val in session.execute("select * from videos_by_tag"):
print('{0:12} {1:40} {2:5}'.format(val[0], val[2], val[3]))
session.execute(
View untrusted-lvl4-solution.js
/*******************
* multiplicity.js *
*******************
*
* Out of one cell and into another. They're not giving you
* very much to work with here, either. Ah, well.
*
* Level filenames can be hints, by the way. Have I
* mentioned that before?
*