This file contains 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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(100); |
This file contains 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 | |
# coding: utf-8 | |
# twitcasting_record.sh by Natata | |
# modified from showroom.sh by fcicq | |
# NOTE: need to install jq and livestreamer first | |
(jq --version 1>/dev/null 2>&1) || (echo 'install jq first'; exit) | |
(livestreamer --version 1>/dev/null 2>&1) || (echo 'install livestreamer first (run pip/pip3 install livestreamer)'; exit) | |
if [ -n "$1" ]; then |
This file contains 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
extension CMDeviceMotion { | |
func gaze(atOrientation orientation: UIInterfaceOrientation) -> SCNVector4 { | |
let attitude = self.attitude.quaternion | |
let aq = GLKQuaternionMake(Float(attitude.x), Float(attitude.y), Float(attitude.z), Float(attitude.w)) | |
let pi2 = Double.pi/2 | |
let final: SCNVector4 | |
switch UIApplication.shared.statusBarOrientation { |
This file contains 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
func recoverFactory(f func()) func() { | |
rf := func() { | |
defer func() { | |
if r := recover(); r != nil { | |
fmt.Println("Recovered in f", r, "ker") | |
} | |
}() | |
f() | |
} |
This file contains 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
// | |
// Downloader.swift | |
// | |
// Created by Natata on 2017/9/15. | |
// Copyright © 2017 Natata. All rights reserved. | |
// | |
import Foundation | |
import Alamofire |
This file contains 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
// source: http://www.cnblogs.com/over140/p/4837652.html | |
class UILabelPadding : UILabel { | |
private var padding = UIEdgeInsets.zero | |
@IBInspectable | |
var paddingLeft: CGFloat { | |
get { return padding.left } | |
set { padding.left = newValue } |
This file contains 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
FROM ubuntu:16.04 | |
MAINTAINER natataworld@love.com | |
ARG USER=docker_user | |
RUN apt-get update && apt-get -y install cron sudo | |
# create a normal user | |
RUN adduser --disabled-password --gecos '' $USER | |
RUN adduser $USER sudo |
This file contains 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
func createOrOpenFile(dir, fn string) (*os.File, error) { | |
if _, err := os.Stat(dir); os.IsNotExist(err) { | |
err := os.Mkdir(dir, 0700) | |
if err != nil { | |
log.Infof("mkdir %v fail", dir) | |
return nil, err | |
} | |
} | |
fallPath := filepath.Join(dir, fn) |
This file contains 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
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"strings" | |
) | |
func sayHello(w http.ResponseWriter, r *http.Request) { |
This file contains 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/sh | |
# usage: | |
# ./go_installer_mac.sh [go version] | |
# | |
# example install go 1.10.2: | |
# ./go_installer_mac.sh 1.10.2 | |
set -uex |
OlderNewer