Skip to content

Instantly share code, notes, and snippets.

View block-test.js
const {__} = wp.i18n; // Import __() from wp.i18n
const {registerBlockType} = wp.blocks; // Import registerBlockType() from wp.blocks
const {
RichText
} = wp.blockEditor;
/**
* Register block
*/
export default registerBlockType(
"tct/article-card-block",
@mkaz
mkaz / prime-numbers-1.py
Last active Apr 23, 2019
The Sieve of Eratosthenes - Find primes in Python, Golang, and C
View prime-numbers-1.py
#!/usr/bin/env python3
import os, string
max = 1000000
# seed list with first two primes
primes = [2,3]
# set number
start_num = 4
@mkaz
mkaz / in-space.py
Created Feb 25, 2019
People currently in Space
View in-space.py
#!/usr/bin/env python3
""" How many people currently in space """
import json, requests, sys
response = requests.get('http://api.open-notify.org/astros.json')
data = response.json()
print(data["number"])
sys.exit(0)
View 10-scala-one-liners-to-impress-your-friends.md

10 Scala One Liners to Impress Your Friends

Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.

Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.

1. Multiple Each Item in a List by 2

The map function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o

@mkaz
mkaz / keybase.md
Created Jul 14, 2014
Keybase proof
View keybase.md

Keybase proof

I hereby claim:

  • I am mkaz on github.
  • I am mkaz (https://keybase.io/mkaz) on keybase.
  • I have a public key whose fingerprint is E4E8 4E24 A94F A670 39A5 F6A7 E82A EA62 82C4 BC5F

To claim this, I am signing this object:

@mkaz
mkaz / index.html
Created Oct 2, 2012 — forked from thomasboyt/index.html
SquiggleVision Graphing
View index.html
<html>
<head>
<title>Squiggle Demo</title>
<script src="http://d3js.org/d3.v2.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js "></script>
<script src="squiggle.js"></script>
<style>
@font-face {
@mkaz
mkaz / index.html
Created Oct 2, 2012
xkcd graph style in d3
View index.html
<!DOCTYPE html>
<head>
<style>
@font-face {
font-family: 'xkcd';
src: url('http://dl.dropbox.com/u/12305244/Humor-Sans.ttf');
}
body {
font-size: 14px;
@mkaz
mkaz / web_timing.py
Created Jul 4, 2012
Use Selenium to Measure Web Timing
View web_timing.py
#!/usr/bin/env python
"""
Use Selenium to Measure Web Timing
Performance Timing Events flow
navigationStart -> redirectStart -> redirectEnd -> fetchStart -> domainLookupStart -> domainLookupEnd
-> connectStart -> connectEnd -> requestStart -> responseStart -> responseEnd
-> domLoading -> domInteractive -> domContentLoaded -> domComplete -> loadEventStart -> loadEventEnd
You can’t perform that action at this time.