Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:

Jesse Lawson jesselawson

:shipit:
View GitHub Profile
View c157-example2.py
"""
Example 2
Introducing both kinds of comments, and using them to explain in detail the
elements of Example 1.
"""
# A 'comment' is code that is ignored by a language's compiler or interpreter.
# Python ignores any line that starts with the octothorpe (`#`).
# You might be more familiar with the term 'hash' or 'pound sign' for the # character.
@jesselawson
jesselawson / main.rs
Last active Oct 22, 2019
parse_markdown_file() function testing
View main.rs
use std::path::Path;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::io::Write;
fn parse_markdown_file(_filename: &str) {
print_short_banner();
println!("[ INFO ] Starting parser!");
@jesselawson
jesselawson / main.rs
Last active Oct 22, 2019
Fifth Checkpoint, Getting Started with Rust by Building a Tiny Markdown Compiler (https://jesselawson.org/tutorials)
View main.rs
// Code for the Fifth Checkpoint
// Tutorial: https://jesselawson.org/rust/get-started-with-rust-by-building-a-tiny-markdown-compiler/
//
// The purpose of this checkpoint is to ensure that you have a complete copy
// of the code in the tutorial up to the checkpoint. I want you to tinker and
// explore, but to keep up with the rest of the tutorial, make sure your
// code matches this checkpoint.
use std::path::Path;
use std::fs::File;
@jesselawson
jesselawson / main.rs
Last active Oct 22, 2019
Fourth Checkpoint, Getting Started with Rust by Building a Tiny Markdown Compiler (https://jesselawson.org/tutorials)
View main.rs
// Code for the Fourth Checkpoint
// Tutorial: https://jesselawson.org/rust/get-started-with-rust-by-building-a-tiny-markdown-compiler/
//
// The purpose of this checkpoint is to ensure that you have a complete copy
// of the code in the tutorial up to the checkpoint. I want you to tinker and
// explore, but to keep up with the rest of the tutorial, make sure your
// code matches this checkpoint.
fn parse_markdown_file(_file: &str) {
println!("[ INFO ] Trying to parse {}...", _file);
@jesselawson
jesselawson / main.rs
Last active Oct 22, 2019
Third Checkpoint, Getting Started with Rust by Building a Tiny Markdown Compiler (https://jesselawson.org/tutorials)
View main.rs
// Code for the Third Checkpoint
// Tutorial: https://jesselawson.org/rust/get-started-with-rust-by-building-a-tiny-markdown-compiler/
//
// The purpose of this checkpoint is to ensure that you have a complete copy
// of the code in the tutorial up to the checkpoint. I want you to tinker and
// explore, but to keep up with the rest of the tutorial, make sure your
// code matches this checkpoint.
fn parse_markdown_file() {
// This will be created in Chapter 4
@jesselawson
jesselawson / main.rs
Last active Oct 22, 2019
Second Checkpoint, Getting Started with Rust by Building a Tiny Markdown Compiler (https://jesselawson.org/tutorials)
View main.rs
// Code for the Second Checkpoint
// Tutorial: https://jesselawson.org/rust/get-started-with-rust-by-building-a-tiny-markdown-compiler/
//
// The purpose of this checkpoint is to ensure that you have a complete copy
// of the code in the tutorial up to the checkpoint. I want you to tinker and
// explore, but to keep up with the rest of the tutorial, make sure your
// code matches this checkpoint.
fn get_version() -> u16 {
1000
@jesselawson
jesselawson / dynamic_strings_example.c
Created Apr 24, 2019
An example of how you can use malloc(), realloc(), and free() to create dynamic strings.
View dynamic_strings_example.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
// sizeof(char) is always 1, but we have it here
// for instructional purposes
char* full_name = malloc(sizeof(char)*strlen("Jesse Lawson")+1);
strcpy(full_name, "Jesse Lawson");
@jesselawson
jesselawson / bad_string_literals.c
Created Apr 23, 2019
An example of how string literals persist in stack memory. This is NOT how you do dynamic strings!
View bad_string_literals.c
#include <stdio.h>
#include <string.h>
int main(void) {
char* full_name = "Jesse Lawson";
char* ptr = full_name;
printf("newptr: %p\n", ptr);
full_name = "Jesse Happy Bubble Fun Club Lawson";
ptr = full_name;
printf("newptr: %p\n", ptr);
View keybase.md

Keybase proof

I hereby claim:

  • I am jesselawson on github.
  • I am jesselawson (https://keybase.io/jesselawson) on keybase.
  • I have a public key ASBc9tUfZoktBJkb1UcDaFOiL8gmNK9ADR2jBlZjnT1CFgo

To claim this, I am signing this object:

@jesselawson
jesselawson / ExportSchema.ps1
Last active May 23, 2018 — forked from cheynewallace/ExportSchema.ps1
Export MSSQL schema with PowerShell. This script will export your schema definitions for tables, stored procs, triggers, functions and views to .sql files
View ExportSchema.ps1
# Usage: powershell ExportSchema.ps1 "SERVERNAME" "DATABASE" "C:\<YourOutputPath>"
# Start Script
Set-ExecutionPolicy RemoteSigned
# Set-ExecutionPolicy -ExecutionPolicy:Unrestricted -Scope:LocalMachine
function GenerateDBScript([string]$serverName, [string]$dbname, [string]$scriptpath)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
You can’t perform that action at this time.