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
| BUFFER_SIZE = 900 | |
| buffer = [0] * BUFFER_SIZE | |
| index = 0 | |
| total = 0 | |
| count = 0 | |
| def moving_average(new_value): | |
| global index, total, count | |
| if count < BUFFER_SIZE: |
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
| #include <stdio.h> | |
| #define BUFFER_SIZE 900 // 循環緩衝區大小 | |
| // 移動平均結構體 | |
| typedef struct { | |
| int buffer[BUFFER_SIZE]; // 循環緩衝區 | |
| int sum; // 總和 | |
| int count; // 目前個數 | |
| int index; // 當前索引 |
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
| #!/bin/bash | |
| for dir in $PWD/*/ # list directories in the form "/xxx/dirname/" | |
| do | |
| dir=${dir%*/} # remove the trailing "/" | |
| # echo "${dir##*/}" # print everything after the final "/" | |
| pushd "${dir##*/}" && git pull --recurse-submodules && popd | |
| done |
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
| #!/usr/bin/env python3 | |
| # Android signed images extractor. To use the script: | |
| # | |
| # python3 signimg2img -u vendor-sign.img # to unpack any other image. | |
| # | |
| # display("USAGE: signimg2img.py -option:\n") | |
| # print(" -u image-sign.img: Unsigns the given image. (If is system will unpack it)") | |
| # print(" -o: Get image info (-o image_name).") | |
| # print(" -c: Full cleanup (removes all!)") | |
| # print("") |
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
| #!/bin/bash | |
| #cd /home/pi/space/source | |
| while true; do | |
| python2 .repo/repo/repo sync -f -n -c -j4 --no-repo-verify --optimized-fetch | |
| #ls -la | |
| RETVAL=$? | |
| [ $RETVAL -eq 0 ] && echo "Repo sync success!" && exit 0 | |
| printf '%s\n' 'Repo sync failed, will start retry in 5 minutes...' | |
| sleep 300 | |
| done |
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 pygame | |
| FPS = 30 | |
| BG_IMG = "bg.jpg" | |
| class SkyNet(): | |
| def __init__(self): | |
| pygame.init() | |
| pygame.display.set_mode((0, 0), pygame.FULLSCREEN) | |
| self._surface = pygame.display.get_surface() | |
| self._running = True | |
| self.bg = pygame.image.load(BG_IMG) |
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
| # -*- coding: utf-8 -*- | |
| # D:ffmpeg -i "KTV 小幸運.mp4" -target ntsc-vcd final_video.mpg | |
| import glob | |
| import os | |
| COMMAND = u'D:ffmpeg -i "{}" -target ntsc-vcd "{}.mpg"' | |
| files = glob.glob('*.mp4') | |
| for f in files: | |
| c = COMMAND.format(f,f.split(".")[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
| """ | |
| https://open.kattis.com/problems/aliennumbers | |
| Input | |
| #alien_number source_language target_language | |
| 4 | |
| 9 0123456789 oF8 | |
| Foo oF8 0123456789 | |
| 13 0123456789abcdef 01 | |
| CODE O!CDE? A?JM!. |
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 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 numpy as np | |
| #O(N*W) | |
| def solve(v,wlist,totalWeight,totalLength): | |
| c = np.zeros((totalLength+1,totalWeight+1),dtype=np.int32) # c(4,51) | |
| for i in range(1,totalLength+1): | |
| for w in range(1,totalWeight+1): | |
| if wlist[i] > w: | |
| c[i,w] = c[i-1,w] | |
| else: |
NewerOlder