Skip to content

Instantly share code, notes, and snippets.

Steven Schveighoffer schveiguy

  • Massachusetts
Block or report user

Report or block schveiguy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@schveiguy
schveiguy / raindrops.d
Created Sep 4, 2019
Raindrops demo code.
View raindrops.d
import std.algorithm;
void main(string[] args)
{
import std.stdio;
// args[0] is the program name, args[1] through args[n] are the input strings.
// first validate the input
auto input = args[1 .. $];
foreach(i; 1 .. input.length)
{
@schveiguy
schveiguy / gblevelup.d
Last active Sep 5, 2019
Golf Blitz level checker
View gblevelup.d
import std.algorithm;
import std.range;
import std.string;
import std.array;
import std.conv;
// |level|common|rare|epic|bux|xp|xptonextlevel|
enum xpData =
`|1|1|1|1|5|4|8|
|2|2|1|1|6|5|10|
@schveiguy
schveiguy / test.html
Created May 26, 2017
Simple web page with one table
View test.html
<html>
<body>
before
<table>
<tr>
<td>table</td><td>data</td>
</tr>
</table>
after
</body>
@schveiguy
schveiguy / eponymous.d
Last active May 27, 2017
Voldemort types article
View eponymous.d
module eponymous;
template inputChain(R1, R2)
if(isInputRange!R1 && isInputRange!R2 &&
is(ElementType!R1 == ElementType!R2))
{
auto inputChain(R1 r1, R2 r2)
{
...
}
@schveiguy
schveiguy / ex1_a.d
Last active Aug 29, 2016
2.071.0 import article
View ex1_a.d
module ex1_a;
void foo() {}
@schveiguy
schveiguy / local_ref.d
Last active Feb 22, 2016
D inout article
View local_ref.d
struct LocalRef(T)
{
private T* _ref;
this(ref T t) { _ref = &t; }
ref T get() pure { return *_ref; }
}
void main()
{
int x;
@schveiguy
schveiguy / struct_with_properties.swift
Last active Feb 22, 2016
Code for swift/d comparison
View struct_with_properties.swift
struct S
{
var x : Int // uses hidden storage
var xTimes10 : Int {
get {
return x * 10
}
set {
x = newValue / 10
}
You can’t perform that action at this time.