This file contains hidden or 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 tgpu from 'typegpu' | |
| import { type AnyData, type InferGPU, u32 } from 'typegpu/data' | |
| /** | |
| * Creates a cache for values computed at most once per shader invocation. | |
| * Each cache supports up to 32 values. | |
| */ | |
| export function createInvocationCache() { | |
| const hasValueMask = tgpu.privateVar(u32) | |
| let nextBit = u32(0) |
This file contains hidden or 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
| // exported types will be available for you to import from compiled files | |
| // to distinguish between objects ({}) and blocks, blocks have a colon before the opening brace (:{}) | |
| export type parseRoute = (route: string) => :{ | |
| // assign computations to variables like this | |
| let parts = route.split("/"); // -> ["users", "<id:string>", "posts", "<index:number>"] | |
| // last expression is the return value, like in Rust | |
| parts | |
| // method chaining! | |
| .filter((part) => part.startsWith("<")) // -> ["<id:string>", "<index:number>"] |
This file contains hidden or 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
| export * from './types' | |
| import { setHost, setApiKey } from './req' | |
| import * as auth from './api/auth' | |
| import * as blocks from './api/blocks' | |
| import * as costCodes from './api/cost-codes' | |
| import * as equipment from './api/equipment' | |
| import * as reporting from './api/reporting' | |
| import * as sites from './api/sites' |
This file contains hidden or 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 React, { useState, useEffect } from 'react' | |
| import ItemList from './item-list' | |
| export const CurrentItems = React.createContext([]) | |
| const api = { | |
| async getItems() { | |
| return parseItemsOrWhatev(fetch('http://foo.com/items')) | |
| } | |
| } |
This file contains hidden or 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
| # same as Ch5_1b (loops with user input list of numbers generating the count, total and average) but with max and min values instead of count aveage and total | |
| # Setting the running smallest and largest numbers to none so they are defined | |
| smallest_number = None | |
| largest_number = None | |
| # User input loop | |
| while True: | |
| string_number = input('Enter a number.') | |
| # Denoting end of loop with 'done' and printing output of smallest and largest numbers from user list |
This file contains hidden or 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
| # This program asks for a decimal value and calculates the corresponding | |
| # letter grade. | |
| # Ask the user for the score. | |
| score_as_string = input('Please enter score between 0 and 1: ') | |
| # Convert the string returned by input() to a number. | |
| try: | |
| score = float(score_as_string) | |
| except: |
This file contains hidden or 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
| Compiling code for electron | |
| Including: | |
| /Users/alex/Projects/tower/tower.ino | |
| /Users/alex/Projects/tower/FastLED/bitswap.h | |
| /Users/alex/Projects/tower/FastLED/chipsets.h | |
| /Users/alex/Projects/tower/FastLED/color.h | |
| /Users/alex/Projects/tower/FastLED/colorpalettes.h | |
| /Users/alex/Projects/tower/FastLED/colorutils.h | |
| /Users/alex/Projects/tower/FastLED/controller.h |
This file contains hidden or 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
| var resize_interval; | |
| // resize AFTER resize finished, and don't do again for a second or so | |
| window.onresize=function(){ | |
| // Window was resized, so cancel any previous deferred resize handlers. | |
| clearTimeout(resize_interval); | |
| // Call this every 750ms | |
| resize_interval = setTimeout(function () { | |
This file contains hidden or 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
| var resize_blocker = Date.now(); | |
| var resize_interval; | |
| // resize AFTER resize finished, and don't do again for a second or so | |
| window.onresize=function(){ | |
| // window was resized, so cancel any previous deferred resize handlers. | |
| clearTimeout(resize_interval); | |
| // Call this every 250ms | |
| resize_interval = setTimeout(function () { |
This file contains hidden or 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 UIKit | |
| // test harness | |
| func timeBlock(block: () -> Void) { | |
| let start = clock() | |
| block() | |
| let diff = clock() - start | |
| let msec = diff * 1000 / UInt(CLOCKS_PER_SEC) | |
| print("Time taken: \(msec) milliseconds") | |
| } |
NewerOlder