Skip to content

Instantly share code, notes, and snippets.

@porthunt
porthunt / read_github_json.py
Created August 6, 2021 19:49
Read json file from a private GitHub repository
import base64
import json
import requests
REPO_URL = "https://api.github.com/repos/<USER>/<REPO>/contents/<PATH>/<TO>/<FILE>.json"
TOKEN = "<YOUR PAT OR OAUTH TOKEN>"
headers = {
"Authorization": f"token {TOKEN}",
"Accept": "application/vnd.github.v4+raw"

tmux cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
# please define a very simple singly linked list
# list items: 4 -> 7 -> 2
# item positions: 0 1 2
# please write a function that, given a value and a position, inserts the value into the list at that position
# 4,7,2 => insert 9 at position 1 => 4,9,7,2
class LinkedList(object):
def __init__(self):
HEAD = None
@porthunt
porthunt / MapScript.cs
Last active April 28, 2017 19:23
A different approach to work on the Text101 challenge from Udemy Unity Course
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class World
{
LinkedList<Map> map_list;
Map curr_map;
public World()
import pandas
import operator
import math
import sys
dataframe = None
file_name = None
rating_limits = (0.5, 5.0)
import speech_recognition as sr
'''
Installation:
pip install SpeechRecognition
On OSX: brew install portaudio && brew link portaudio
pip install pyaudio
Check for more info: https://pypi.python.org/pypi/SpeechRecognition/
@porthunt
porthunt / str_conversion.r
Last active March 7, 2016 16:43
String conversion
setwd("C:/Users/user/Desktop") #Use the path that your file is in.
names <- readLines("ALL.txt") #Read file
listOfNames <- ""
for (i in names) { listOfNames <- paste(listOfNames,",",i) }
listOfNames <- gsub(" ", "", listOfNames) #Remove whitespaces
substr(listOfNames, 2, nchar(listOfNames)) #Remove first comma
# Given a file with strings in the following format:
#
# A
/* Developed by: Joao Pedro Portela Gomez Vaz */
/* COMPLETE - Ver. 1.5 */
import java.io.*;
import java.security.*;
import java.util.*;
/* HOW TO RUN */
// 1. cd /your/directory
// 2. javac DigestCalculator.java
import java.security.*;
import javax.crypto.*;
class CreateSignature {
public static void main (String[] args) throws Exception {
// verify args. If args.length is not more (or less) than 1, tells how to use the program.
if (args.length !=1) {
System.err.println("How to use: java CreateSignature your text between \"\"");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rows 4
#define cols 4
void checkIfWinner(char boardMap[rows][cols], int k);
int checkDiagonal(char board[rows][cols], char side);
int checkGameStatus(char board[rows][cols]);