Skip to content

Instantly share code, notes, and snippets.

View aervin's full-sized avatar
👾

aervin_ aervin

👾
View GitHub Profile
@aervin
aervin / example.css
Created June 8, 2018 22:07
alphabetize ur gd style rules
/* this */
p {
color: blue;
font-family: sans-serif;
font-size: 16px;
font-weight: 400;
line-height: 24px;
padding-left: 8px;
}
@aervin
aervin / example.css
Last active June 7, 2018 22:06
CSS external
/* Embarrassing edit: I used the wrong comment style for CSS files... */
/*
CSS can live in its own file, which is imported by the html document. Importing this
stylesheet into an html doc would look something like this (provided the html doc and
the example.css file live in the same directory on your local system):
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="example.css">
@aervin
aervin / index.html
Created June 7, 2018 21:56
CSS inline <style> blocks
<!-- You can save this file locally and open it in your browser for experimentation purposes. -->
<html lang="en">
<head>
<!--
Loads of other stuff lives in the <head> tag, <style>
blocks are just one of many possibilities. Also, multiple <style>
blocks are not uncommon.
-->
@aervin
aervin / preferParameterPropertiesRule.js
Created January 16, 2018 00:50
TSLint rule for preferring parameter properties
exports.Rule = class Rule extends Lint.Rules.AbstractRule {
apply(sourceFile) {
return this.applyWithWalker(new NoTemplateExpressionWalker(sourceFile, this.getOptions()));
}
};
const FAILURE_STRING = `Use parameter properties instead of assigning to members in the constructor body.`;
class NoTemplateExpressionWalker extends Lint.RuleWalker {
walk(sf) {
@aervin
aervin / boolean-prefix.js
Created January 10, 2018 01:42
Implementation of Airbnbs boolean prefix style guideline for TSLint
exports.Rule = class Rule extends Lint.Rules.AbstractRule {
apply(sourceFile) {
return this.applyWithWalker(new NoTemplateExpressionWalker(sourceFile, this.getOptions()));
}
};
class NoTemplateExpressionWalker extends Lint.RuleWalker {
FAILURE_STRING = "Prefix boolean method and property names with words like 'is' or 'has'";
PREFIXES = ["is", "has", "will", "should", "could"];
visitClassDeclaration(node) {
@aervin
aervin / sequencer.html
Last active May 20, 2021 11:11
A simple step sequencer made with HTML, CSS, and JS via the Web Audio API! (Chrome tested only)
<!DOCTYPE html>
<html>
<head>
<style>
button:focus {
outline: none;
}
button.success {
@aervin
aervin / banSyntaxRule.ts
Last active December 24, 2017 14:59
A generic "ban syntax" lint rule for TSLint
import * as ts from "typescript";
import * as Lint from "../index";
export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING_FACTORY(nodeType: string) {
return `Usage of ${nodeType} has been disallowed.`;
}
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(
@aervin
aervin / y-cli.c
Created September 27, 2017 01:35
Send search message to UDP multicast address, parse response
#include <sys/socket.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#define MULTICAST_PORT 1982
#define MULTICAST_HOST "239.255.255.250"
#define UDP_PORT 33333
#define BUFFER_SIZE 1250
@aervin
aervin / http_request.c
Last active September 24, 2017 15:02
C - Basic (and insecure) TCP connection to a weather API
#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#include <netdb.h>
#define RESPONSE_BUFFER 1200