Skip to content

Instantly share code, notes, and snippets.

#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>()));

Keybase proof

I hereby claim:

  • I am Jamesits on github.
  • I am jamesits (https://keybase.io/jamesits) on keybase.
  • I have a public key whose fingerprint is F37F 9BC8 BBE8 C9AB 7EC2 D7E3 5CE8 0C34 0ACC 0CC0

To claim this, I am signing this object:

@Jamesits
Jamesits / esp12e-blink.ino
Last active September 24, 2020 03:22
Blink for ESP8266 ESP-12E NodeMCU 1.0 Board, Arduino IDE: Hello world and function tests.
#!/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/
@Jamesits
Jamesits / update-everything.sh
Last active March 12, 2016 02:40
Functions for updating and upgrading everything.
#!/usr/bin/env bash
update() {
case $1 in
# apt-get
apt)
apt update && apt full-upgrade -y
;;
@Jamesits
Jamesits / 8queen.py
Last active April 10, 2016 14:28
8 Queen Problem, Python 3
#!/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
@Jamesits
Jamesits / josephus-ring.c
Last active July 10, 2016 03:08
C program for solving Josephus Ring.
#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
@Jamesits
Jamesits / jjwxc.css
Created June 30, 2016 04:03
晋江文学城阅读界面优化
/*
by James Swineson, 2016-06-30
Apply to: URL starts with http://www.jjwxc.net/onebook.php?novelid=
*/
body {
background: moccasin !important;
}
body>div {
@Jamesits
Jamesits / measure-net-speed.bash
Created August 6, 2016 14:04
Display net speed.
#!/bin/bash
# Public Domain
# (someone claimed the next lines would be useful for…
# people. So here goes: © 2012 Stefan Breunig
# stefan+measure-net-speed@mathphys.fsk.uni-heidelberg.de)
# modified by James Swineson <github@public.swineson.me>
# interfaces
interfaces=(enp1s0 wlp2s0)
@Jamesits
Jamesits / dec_unicode_encode.py
Last active August 23, 2016 02:02
Delphi decimal encoded character resource encoder/decoder, for char sequence like "#xxxxx#xxxxx".
#!/usr/bin/env python3
# by @Jamesits 2016-08-23
# Great thanks to @m13253
def dec_unicode_decode(s):
return ''.join((bytes([x&255, x>>8]).decode('utf-16-le') for x in map(int, s.split('#')[1:])))
def dec_unicode_encode(s):
return '#' + '#'.join([str(int(x, 16)) for x in str(s.encode("unicode-escape"))[2:-1].split("\\\\u")[1:]])