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
#include <stdlib.h> | |
#include <string.h> | |
#include <stdio.h> | |
typedef struct student { | |
int uid; // unique identifier | |
float gpa; // grade point average | |
char *firstname; | |
char *lastname; | |
} student_t; |
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 os | |
import random | |
import string | |
ALPHABET = string.ascii_lowercase + string.digits | |
def encrypt(password, text): | |
message = "".join([c.lower() if c.isalnum() else "" for c in text]) | |
plaintext = [ALPHABET.find(c.lower()) for c in message] | |
keystream = [ALPHABET.find(c.lower()) for c in password] | |
n = len(plaintext) |
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
function fdmproblem(n) | |
m = n | |
A = zeros(n*m, n*m) | |
dof = reshape(1:n*m, n, m) | |
for i=2:n, j=1:m | |
A[dof[i,j], dof[i-1,j]] -= 1.0 | |
A[dof[i,j], dof[i,j]] += 1.0 | |
end | |
for i=1:n, j=2:m | |
A[dof[i,j], dof[i,j-1]] -= 1.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/sh | |
OUTPUT_DIR="/" | |
MAX_PID=65535 | |
CGROUP_NAME="xyx" | |
CGROUP_MOUNT="/tmp/cgrp" | |
PAYLOAD_NAME="${CGROUP_NAME}_payload.sh" | |
PAYLOAD_PATH="${OUTPUT_DIR}/${PAYLOAD_NAME}" | |
OUTPUT_NAME="${CGROUP_NAME}_payload.out" | |
OUTPUT_PATH="${OUTPUT_DIR}/${OUTPUT_NAME}" |
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
ε_0 = 8.85418781e-12 # vacuum permittivity [F/m] | |
μ_0 = 1.256637062e-6 # vacuum permeability [H/m] | |
c = 299_792_458. # speed of light [m/s] | |
NR = 101 # number of grid points along radial direction [1] | |
NZ = 101 # number of grid points along axial direction [1] | |
RADIUS = 0.010 # radius along r-axis [m] | |
LENGTH = 0.010 # lenght along z-axis [m] | |
DZ = LENGTH / (NZ-1) # cell-size along axial direction [m] | |
DR = RADIUS / (NR-1) # cell-size along radial direction [m] |
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
const H = 20 | |
const W = 20 | |
const f = zeros(9, H, W) | |
const rho = ones(H, W) | |
struct Lattice | |
f :: Array{Float64, 3} | |
end | |
const lattice = Lattice(f) |
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
include("wave-equation.jl") | |
function quadmesh(a, b, Nx, Ny) | |
NUM_EDGES = 2(Nx*Ny) + Nx + Ny | |
NUM_ELEMS = Nx * Ny | |
el2edd = repeat([+1 +1 -1 -1], NUM_ELEMS) | |
el2ed = zeros(Int64, NUM_ELEMS, 4) | |
for jj = 1:Ny | |
for ii = 1:Nx |
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
<!-- | |
Put this file in ~/Library/LaunchAgents/com.example.KeyRemapping.plist to | |
automatically remap your keys when macOS starts. | |
See https://developer.apple.com/library/archive/technotes/tn2450/_index.html for | |
the key "usage IDs". Take the usage ID and add 0x700000000 to it before putting it | |
into a source or destination (HIDKeyboardModifierMappingSrc and | |
HIDKeyboardModifierMappingDst respectively). | |
--> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
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
from json import dumps, loads | |
class Price: | |
def __init__(self, db): | |
self.db = db | |
def __getitem__(self, item): | |
price = self.db.hget("price", item) | |
if price: | |
return int(price) |
NewerOlder