Skip to content

Instantly share code, notes, and snippets.

@syohex
syohex / tuple.cpp
Created September 3, 2016 14:39
Sample code of std::tuple
#include <iostream>
#include <tuple>
#include <string>
std::tuple<std::string, int>
func(int i)
{
if (i == 0) {
return std::tuple<std::string, int>(std::string("hello world"), 0);
} else {
@syohex
syohex / go-add-tag.el
Created August 4, 2016 03:22
Like vim-go's GoAddTags but this has few its features
(defun go-add-tags (type begin end)
(interactive
(list
(or (and current-prefix-arg (completing-read "Type: " '(json yaml toml)))
"json")
(or (and (use-region-p) (region-beginning))
(line-beginning-position))
@syohex
syohex / Cask
Last active December 24, 2018 21:13
My simple Emacs configuration
(source gnu)
(source melpa)
(depends-on "evil")
;; company-mode
(depends-on "company")
;; region
(depends-on "wrap-region")
@syohex
syohex / anzu.diff
Created July 26, 2016 04:14
anzu current prefix key behavior
diff --git a/anzu.el b/anzu.el
index 4d0cf62..84d099d 100644
--- a/anzu.el
+++ b/anzu.el
@@ -408,7 +408,7 @@
(defconst anzu--from-to-separator
(propertize
(or (ignore-errors
- (if (char-displayable-p ?\u2192) " \u2192 " " -> "))
+ (if (char-displayable-p ?\u2192) " \u2192 " " -> "))
@syohex
syohex / git-gutter-list.diff
Created July 24, 2016 03:09
List hunks and jump there
diff --git a/git-gutter.el b/git-gutter.el
index 15dc837..29c0425 100644
--- a/git-gutter.el
+++ b/git-gutter.el
@@ -1057,6 +1057,72 @@ start revision."
(message "Added %d lines, Deleted %d lines" added deleted))
(cons added deleted))))
+(defvar git-gutter:list-mode-map
+ (let ((map (make-sparse-keymap)))
@syohex
syohex / brew.list
Last active July 3, 2016 12:15
my gitconfig without private information
autoconf
automake
bazaar
cmake
coreutils
elixir
erlang
fontconfig
freetype
gauche
@syohex
syohex / netbsd-download.sh
Created June 8, 2016 03:27
Download NetBSD source code archives and extract them
#!/bin/sh
set -e
set -x
for file in src syssrc sharesrc
do
curl -LO http://ftp.jaist.ac.jp/pub/NetBSD/NetBSD-7.0.1/source/sets/${file}.tgz
tar xvf ${file}.tgz
done
@syohex
syohex / json2gostruct.py
Created May 30, 2016 11:43
Convert from JSON to Golang struct definition in Python
#!/usr/bin/env python
import sys
import os
import json
def usage():
print("Usage: json2gostruct.py struct_name")
os.exit(0)
def indent(nest):
@syohex
syohex / json2gostruct.pl
Created May 25, 2016 10:55
Convert JSON to go struct definition
#!perl
use strict;
use warnings;
use JSON::PP ();
use Getopt::Long ();
use Scalar::Util ();
my $struct_name = "";
Getopt::Long::GetOptions(
@syohex
syohex / swoop-narrow.diff
Created May 2, 2016 10:56
Support narrow region in swoop.el
diff --git a/swoop-lib.el b/swoop-lib.el
index d95459c..98cfbdd 100644
--- a/swoop-lib.el
+++ b/swoop-lib.el
@@ -369,6 +369,7 @@ swoop-overlay-target-buffer-selection moved."
($point (point))
($point-min (point-min))
($point-max (point-max))
+ ($min-line (save-restriction (widen) (line-number-at-pos $point-min)))
($max-line (line-number-at-pos $point-max))