This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
function Square({ value, onSquareClick }) { | |
return ( | |
<button className="square" onClick={onSquareClick}> | |
{value} | |
</button> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_id_card_check_digit(card_number: str) -> int: | |
return (11 - sum([(len(card_number) - i) * x for i, x in enumerate(map(lambda s: int(s), card_number[:-1]))]) % 11) % 10 | |
def validate_id_card_number_check_digit(card_number: str) -> bool: | |
return int(card_number[-1:]) == calculate_id_card_check_digit(card_number) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Location: /var/www/ist-fr.vistec.ist | |
# Redirects stdout/stderr to a file | |
exec > ./deploy.log 2>&1 | |
# Add snap bin PATH (npm is here) | |
export PATH=$PATH:/snap/bin | |
# Remove existing repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Media Control Macro Keys Script For AutoHotKey | |
; Version 1.0 | |
; | |
; (C) Benjapol Worakan | |
; | |
; Created out of frustation that my new laptop does not have multimedia hotkeys (e.g. Play/Pause/Next/Previous) | |
; Feel free to use or modify this script :) | |
; RightCtrl+Spacebar = Play/Pause | |
>^Space::Media_Play_Pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Manual compilation - C to MIPS R3000 Assembly | |
# | |
# Shift the first element of an array to position 9 (0-indexed) | |
# | |
# Author: Benjapol Worakan (benwrk) | |
# | |
.data | |
array: .word 0 : 20 # int A[20] // array declaration | |
size: .word 10 # int size = 10 // actual size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.data | |
array: .word 0 : 50 | |
size: .word 50 | |
space: .asciiz " " | |
.text | |
.globl main | |
main: | |
init_value_init: | |
lw $t3, size | |
la $t8, array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
import json | |
API_ENDPOINT = 'http://api.openweathermap.org/data/2.5/forecast/daily' | |
API_KEY = 'PUT API KEY HERE' | |
DAYS = 13 | |
THRESHOLD = 70 | |
def is_dangerous(province, date=0): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.concurrent.Callable; | |
import java.util.concurrent.ExecutionException; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
/** | |
* Add numbers using ExecutorService. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.List; | |
public class IndependentSetOfMaximumWeight { | |
public static void main(String[] args) { | |
System.out.println("Independent set of maximum weight: " | |
+ findIndependentSetOfMaximumWeight(Arrays.asList(6, 8, 7, 6, 8, 1))); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# "Insertion Sort -- Assembly Version" | |
# | |
# This MIPS assembly code -- based on MIPS R3000's instruction set -- first | |
# receives the number of values to be sorted (N), then receives the values | |
# (for N times) to be sorted, and then sort the values using "Insertion Sort" | |
# and prints the result of the sorting. | |
# | |
# Note: Maximum number of values to be sorted (N) is 999 numbers. | |
# |
NewerOlder