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> | |
| #include <stdlib.h> | |
| int main(void) | |
| { | |
| // input arguments (assuming n, k > 0) | |
| int n, k; | |
| scanf("%d%d", &n, &k); | |
| // initialize number -> position mapping array |
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 | |
| # 8 Queens Problem | |
| # by James Swineson | |
| from functools import reduce | |
| # 一个棋盘的表示,其中 .board[i] 表示第 i 行的旗子在第几列 | |
| class nQueenBoard: | |
| def __init__(self, size, board=[]): | |
| self.size = 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
| #!/usr/bin/env bash | |
| update() { | |
| case $1 in | |
| # apt-get | |
| apt) | |
| apt update && apt full-upgrade -y | |
| ;; | |
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 bash | |
| # dotfiles utility - https://gist.github.com/Jamesits/9bc4adfb1f299380c79e | |
| # Set $DOTFILES to where you want to put your dotfiles. | |
| # then run dotfiles-init someSoftware, | |
| # and it will move all files starting with `.someSoftware` to the correct location | |
| # then link them back, | |
| # Which will produce a directory structure like: | |
| # | |
| # $ tree -aL 2 ~/Dropbox/Code/config/dotfiles/ |
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
| // See the comment for flashing instruction. | |
| #include <ESP8266WiFi.h> | |
| #define ONBOARD_LED 16 | |
| #define ESP8266_LED 2 | |
| // ADC_MODE(ADC_VCC); will result in compile error. use this instead. | |
| int __get_adc_mode(void) { return (int) (ADC_VCC); } | |
| void setup() |
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 <iostream> | |
| #include <regex> | |
| #include <fstream> | |
| #include <string> | |
| using namespace std; | |
| int main() { | |
| std::ifstream ifs("sample.in"); | |
| std::string var((std::istreambuf_iterator<char>(ifs)), | |
| (std::istreambuf_iterator<char>())); |
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 | |
| # James' Gene T-tester | |
| # Written by James Swineson <jamesswineson@gmail.com>, 2016-01-27 | |
| # All rights reserved. | |
| # | |
| # Install dependencies: | |
| # pip3 install numpy scipy | |
| # | |
| # Tested to work under Python 3.5.1 on OS X 10.11.3 |
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
| /* | |
| String padding | |
| by James Swineson (@Jamesits) | |
| https://gist.github.com/Jamesits/30acd725d5fdfb67eae4 | |
| Make a string fixed length by adding blank chars between or after it. | |
| Usage: | |
| "123".lpadding(5) // returns " 123" | |
| "123".lpadding(5, "0") // returns "00123" | |
| "123".lpadding(2) // returns "23" | |
| "123".rpadding(5) // returns "123 " |
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 | |
| echo "Updating hosts..." | |
| wget --show-progress -O hosts -- https://github.com/StevenBlack/hosts/raw/master/hosts && /etc/init.d/dnsmasq restart | |
| echo "Update finished. " |
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
| // Love-o-meter rewritten code | |
| // by James Swineson, 2015-10-13 | |
| // For demonstration use only. | |
| // =========== Settings =========== | |
| // Total LED number | |
| #define LEDCOUNT 5 | |
| // Which digital pins are LEDs connected to. They will light up from left to right. |