Skip to content

Instantly share code, notes, and snippets.

@Fogest
Fogest / stock-autofill.user.js
Created August 15, 2020 16:43
stock-autofill.user.js
// ==UserScript==
// @name Stock Autofill
// @namespace PapaAndreas [2169463]
// @version 1.0
// @description Autofills the values in the stock order page of a company
// @author PapaAndreas [2169463]
// @match https://www.torn.com/companies.php
// @updateURL https://openuserjs.org/meta/PapaAndreas/Stock_Autofill.meta.js
// @license MIT
// @run-at document-end

This answer is supposing that you want to roll your own parser using Standard C. In practice it is usually better to use an existing parser because they have already thought of and handled all the weird things that can come up.

My high level approach would be:

  • Read a line
  • Pass pointer to start of this line to a function parse_line:
    • Use strcspn on the pointer to identify the location of the first : or ; (aborting if no marker found)
    • Save the text so far as the property name
    • While the parsing pointer points to ;:
  • Call a function extract_name_value_pair passing address of your parsing pointer.
@Fogest
Fogest / examples.py
Created November 12, 2014 16:44
Example of what you probably will need to know for CIS 1250 exam
#!/usr/bin/python
#You need to be able to declare variables and take in inputs, so let's do that!
userInputString = raw_input() #Input: Hello World (String)
userInputInt = raw_input() #Input: 10 (int)
userInputFloat = raw_input() #Input: 10.532523 (Float)
#We want userInputInt to be an integer, right now it is stored as a string. Convert to int:
userInputInt = int(userInputInt)
#We also need to convert userInputFloat to a float as it is also a string right now:
@Fogest
Fogest / Main_Program.ino
Last active March 13, 2018 16:49
Our code for our Adruino based firefighting robot
#include <LiquidCrystal.h>
#include <Servo.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13,12,11,10,9,8);
Servo servo;
int servoPos = 0;
@Fogest
Fogest / .gitignore
Created March 2, 2014 19:04
Default gitignore file.
# Eclipse stuff
/.classpath
/.project
/.settings
/.checkstyle
/lib
# netbeans
/nbproject
# we use maven!
package com.justin.main;
import java.util.Scanner;
/**
* @author Justin
*
* @title Disemvoweler Remove all values from a given string. Output the string
* without the vowels along with the vowels that were removed
*
@Fogest
Fogest / gist:7836948
Created December 7, 2013 03:31
Find a unique year
package test1;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Question1
{
public static void main(String[] args)
{
package main;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Boolean checker = true;