Skip to content

Instantly share code, notes, and snippets.

@Bostonncity
Bostonncity / povray.vim
Created October 24, 2015 21:51 — forked from ktopolski/povray.vim
Povray command for VIM
" compile POVRay script being currently edited, clear output and open the resulting .png ONLY when povray complilation succeeds.
command Povray !povray % && clear && feh %<.png
" delete the generated .png when exiting from .pov file of the same name.
autocmd BufWinLeave *.pov :!rm %<.png
func wordRangeAtIndex(index:Int, inString str:NSString) -> NSRange {
let tagger = NSLinguisticTagger(tagSchemes: [NSLinguisticTagSchemeTokenType], options: 0)
var r : NSRange = NSMakeRange(0,0)
tagger.string = str as String
tagger.tagAtIndex(index, scheme: NSLinguisticTagSchemeTokenType, tokenRange: &r, sentenceRange: nil )
return r
}
func wordAtIndex(index:Int, inString str:NSString) -> NSString {
return str.substringWithRange(wordRangeAtIndex(index, inString: str))
@Bostonncity
Bostonncity / MailgunTransport.php
Created December 5, 2015 10:46
Send mail using Mailgun and CakePHP 3.0 (Quick and minimal code)
<?php
namespace Cake\Mailer\Transport;
use Cake\Mailer\AbstractTransport;
use Cake\Mailer\Email;
use Mailgun;
/**
* Send mail using Mailgun
@Bostonncity
Bostonncity / AutofacConfig
Created December 5, 2015 19:44 — forked from 3nth/AutofacConfig
AutofacConfig for ASP.NET Identity
public class AutofacConfig
{
public static void Configure()
{
var builder = new ContainerBuilder();
builder.RegisterType<ApplicationDbContext>().AsSelf().InstancePerLifetimeScope();
builder.RegisterType<ApplicationUserStore>().As<IUserStore<PortalUser>>().InstancePerLifetimeScope();
builder.RegisterType<ApplicationUserManager>().AsSelf().InstancePerLifetimeScope();
builder.RegisterType<ApplicationSignInManager>().AsSelf().InstancePerLifetimeScope();
#!/bin/bash
# 判斷是否為 root 身份
if [ "`whoami`" != "root" ]; then
echo "You may use root permission!"
exit 1
fi
# 安裝必要軟體
apt-get install -y git
apt-get install -y pidgin
http://blog.hashrocket.com/posts/feature-development-with-git-branching
@Bostonncity
Bostonncity / gsm.py
Created December 6, 2015 08:05 — forked from jhavard/gsm.py
Decoder for WSR-88D General Status Message
import struct
BLOCK_DIVIDER = 10
LENGTH_OF_BLOCK = 11
MODE_OF_OPERATION = 12
VCP = 14
ELEVATION_CUTS = 15
ELEVATION_01 = 16
ELEVATION_02 = 17
ELEVATION_03 = 18
#loader {
background: none repeat scroll 0 0 #ffffff;
bottom: 0;
height: 100%;
left: 0;
position: fixed;
right: 0;
top: 0;
width: 100%;
z-index: 9999;
[keita@ip-172-31-28-2 toy_app]$ git add -A
[keita@ip-172-31-28-2 toy_app]$ git commit -m "修正"
[master 18f8fa6] 修正
[keita@ip-172-31-28-2 toy_app]$ git remote add origin https://github.com/keita03301995/toy_app.git
fatal: remote origin already exists.
[keita@ip-172-31-28-2 toy_app]$ git push -u origin master
Username for 'https://github.com': keita03301995
Password for 'https://keita03301995@github.com':
Counting objects: 145, done.
Compressing objects: 100% (129/129), done.
<html><head><style>
.main .line {
clear: both;
}
.main .line div {
width: 20px;
height: 20px;
float: left;
margin: 1px;
border: 1px solid #ddd;