Skip to content

Instantly share code, notes, and snippets.

Avatar

Anton Istomin ReFruity

View GitHub Profile
View SCII Bot Development.md

Starcraft 2 Bot Development

  1. Have a Macbook
  2. Install or update Xcode to latest version
  3. Download latest SCII https://github.com/Blizzard/s2client-proto
  4. Unpack it in home directory
  5. Build API in your projects directory:
    git clone --recursive https://github.com/Blizzard/s2client-api
    cd s2client-api
View sample.js
const fs = require('fs')
const Discord = require('discord.js')
const config = require('./config')
const discordClient = new Discord.Client()
async function playFile(connection, filePath) {
return new Promise((resolve, reject) => {
const dispatcher = connection.play(filePath)
dispatcher.setVolume(1)
@ReFruity
ReFruity / index.js
Last active May 14, 2020
Simplified version of EzBot
View index.js
require('dotenv').config()
const Discord = require('discord.js')
const config = require('./config')
const { Transform } = require('stream')
const googleSpeech = require('@google-cloud/speech')
async function playFile(connection, filePath) {
return new Promise((resolve, reject) => {
const dispatcher = connection.play(filePath)
dispatcher.setVolume(1)
@ReFruity
ReFruity / commit-msg
Created Nov 13, 2018
Git commit-msg hook
View commit-msg
#!/bin/bash
filename="$1"
read -r line < "$filename"
if [[ "$line" =~ ^\[ABG-[0-9]+\].* ]] || [[ "$line" =~ ^Merge.* ]]; then
exit 0
fi
@ReFruity
ReFruity / .gitignore
Created Nov 26, 2015
Benefits gitignore
View .gitignore
.gradle
.idea
*.iml
/classes
/domain/build
/web/build
/test/__output__
/imaging/build
/imaging/*.log
/common/build
View Clean Code G15
### G15: Selector Arguments
There is hardly anything more abominable than a dangling false argument at the end of a function call. What does it mean? What would it change if it were true? Not only is the purpose of a selector argument difficult to remember, each selector argument combines many functions into one. Selector arguments are just a lazy way to avoid splitting a large function into several smaller functions. Consider:
public int calculateWeeklyPay(boolean overtime) {
int tenthRate = getTenthRate();
int tenthsWorked = getTenthsWorked();
int straightTime = Math.min(400, tenthsWorked);
int overTime = Math.max(0, tenthsWorked - straightTime);
int straightPay = straightTime * tenthRate; double overtimeRate = overtime ? 1.5 : 1.0 * tenthRate;
You can’t perform that action at this time.