Skip to content

Instantly share code, notes, and snippets.

Avatar
🦠
#WFH

Simon Morgan drguildo

🦠
#WFH
View GitHub Profile
@drguildo
drguildo / bisbic.c
Last active Sep 16, 2020
Solution to Practice Problem 2.13 in Computer Systems: A Programmer's Perspective.
View bisbic.c
#include <stdio.h>
void dump(unsigned int i) {
printf("%#08x = %d\n", i, i);
}
/* Declarations of functions implementing operations bis and bic */
int bis(int x, int m) {
return x | m;
}
View option_move.rs
fn foo1() {
let foo: Option<i32> = Some(1234);
println!("{}", foo.unwrap_or(4321));
let bar = foo;
}
fn foo2() {
let foo: Option<String> = Some("1234".to_string());
println!("{}", foo.unwrap_or("4321".to_string()));
View fs.zig
const std = @import("std");
const fs = std.fs;
const warn = std.debug.warn;
pub fn main() !void {
const cwd = try fs.cwd().openDir(".", fs.Dir.OpenDirOptions{
.iterate = true,
});
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
View lol.zig
const std = @import("std");
const fs = std.fs;
const warn = std.debug.warn;
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
const cwd = try fs.cwd().openDir(".", fs.Dir.OpenDirOptions{
View bf.nim
import os
import streams
import system
import tables
var data: array[30_000, byte]
var dataPointer: int = 0
var instructions: seq[char]
var instructionPointer: int = 0
@drguildo
drguildo / covariance-and-contravariance.cs
Last active Feb 4, 2020
Covariance and contravariance.
View covariance-and-contravariance.cs
static void SetObject(object o) { }
void Main()
{
// Assignment compatibility.
string str = "test";
// An object of a more derived type is assigned to an object of a less derived type.
object obj = str;
// Covariance.
View HashSetContainsEquality.cs
class Foo : IEquatable<Foo>
{
public int Id { get; private set; }
public Foo(int id)
{
this.Id = id;
}
public bool Equals(Foo other)
@drguildo
drguildo / SubredditImageDownloader.ps1
Last active Mar 27, 2020
A PowerShell script for downloading all of the images posted in a subreddit.
View SubredditImageDownloader.ps1
param (
[Parameter(Mandatory = $true)] [string]$Subreddit
)
$UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FSL 7.0.6.01001)"
$StartingDirectory = Get-Location
function getFilename([string]$url) {
$uri = New-Object -TypeName Uri -ArgumentList $url
View CI Tools.markdown

Requirements

  • .NET / ASP.NET Support
  • Test runner
  • Good documentation
  • How well does it work with ASP.NET Web Forms?

Jenkins

View set2Question4.java
import java.io.*;
import java.util.*;
class Main {
static public int EvenOddDigitsSum(int input1, String input2) {
int sum = 0, temp, num = 0;
if (input2 == "even") {
temp = input1;
while (temp != 0) {
System.out.println("Checking " + temp);