Skip to content

Instantly share code, notes, and snippets.

var copyUrl = (e) => {
e.clipboardData.setData('text/plain', document.title + ' ' + location.href);
e.preventDefault();
document.removeEventListener('copy', copyUrl);
}
document.addEventListener('copy', copyUrl);
document.execCommand('copy');
@onozaty
onozaty / MeatMenu.java
Last active July 17, 2018 03:31
2018-07-11 リファクタリング
package com.example;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class MeatMenu {
private final List<Menu> allMenus;
@onozaty
onozaty / Score.java
Last active July 15, 2018 11:34
2018-05-16 リファクタリング
package com.example;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class MeatMenu {
private final List<Menu> allMenus;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@onozaty
onozaty / gist:b36bdf49872e76c3139b
Last active April 6, 2017 04:08
Slide and scroll sidebar by Redmine view customize plugin
$(function() {
$('#content')
.css({
'width': 'auto',
'padding-right': '20px'
});
var sidebar = $('#sidebar');
var sidebarBaseHeight = sidebar.height();
@onozaty
onozaty / gist:a684d5e8087f03bc20c6
Created April 21, 2015 15:42
Better checkbox field by Redmine view customize plugin
// Path pattern: /issues/
// Type : JavaScript
$(function() {
$('.check_box_group')
.each(function() {
var checkBoxGroup = $(this);
checkBoxGroup.hide();
var checkedValueLine =
@onozaty
onozaty / gist:8501987
Created January 19, 2014 08:31
System/Linq/Enumerable.cs
public static bool Any<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) {
if (source == null) throw Error.ArgumentNull("source");
if (predicate == null) throw Error.ArgumentNull("predicate");
foreach (TSource element in source) {
if (predicate(element)) return true;
}
return false;
}
public static bool All<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) {
int[] empty = new int[0];
Console.WriteLine(
empty.Any(x => x % 2 == 0)); // => False
Console.WriteLine(
empty.All(x => x % 2 == 0)); // => True
@onozaty
onozaty / gist:6342227
Last active December 21, 2015 17:39
var clipboard = require("sdk/clipboard");
// 設定
clipboard.set("xxxx");
// 取得
var contents = clipboard.get();
@onozaty
onozaty / gist:6342405
Last active December 21, 2015 17:39
copy to clipboard on xul base addon.
const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
// 設定
gClipboardHelper.copyString("xxxx");