Skip to content

Instantly share code, notes, and snippets.

@gonzoooooo
gonzoooooo / openGoogleSearchFromDuckDuckGo.js
Created August 30, 2022 02:28
DuckDuckGoの検索画面からGoogleの検索画面を開くブックマークレット
javascript:(function(){var url=location.href;if(url.startsWith("https://duckduckgo.com")){var query=location.search;var googleURL="https://www.google.com/search"+query;window.open(googleURL)};})();
@gonzoooooo
gonzoooooo / createScrapboxPageFromGyazo.js
Last active August 19, 2022 02:33
Gyazo から Scrapbox のページを作成するブックマークレット
javascript:(function() {
var project = 'YOUR_PROJECT_NAME';
var url = `https://scrapbox.io/${project}/`;
var gyazoUrl = location.href;
var ocrText = document.getElementsByClassName('ocr-desc-text')[0].innerText;
var title = document.getElementsByClassName('image-desc-display')[0].innerText;
var lines = [`[${gyazoUrl}]`, '', ocrText, ''];
var body = encodeURIComponent(lines.join('\n'));
window.open(url + encodeURIComponent(title.trim()) + '?body=' + body)
}
@gonzoooooo
gonzoooooo / ResizingImageBarButtonItem.swift
Created November 6, 2019 00:23
UIBarButtonItem のアイコンをリサイズする
import UIKit
extension UIImage {
func scale(to newSize: CGSize) -> UIImage {
UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0)
draw(in: CGRect(x: 0.0, y: 0.0, width: newSize.width, height: newSize.height))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage ?? self
@gonzoooooo
gonzoooooo / search_domain.rb
Last active March 14, 2019 04:12
.com と .jp のドメインの空きがあるか検索する
#!/usr/bin/env ruby
require "open3"
%w[.com .jp].map { |d| "#{ARGV[0]}#{d}" }.each do |domain|
out, = Open3.capture3("whois #{domain}")
puts "#{domain} is #{out.downcase.include?("no match")}"
end
@gonzoooooo
gonzoooooo / convertArrayToDictonary.swift
Last active April 21, 2017 02:47
Swift 3 で Array から Dictionary に変換するサンプル
import Foundation
struct Person {
var number: Int
var name: String
}
let persons = [Person(number: 1, name: "John"),
@gonzoooooo
gonzoooooo / wg1800hp2_reboot.sh
Last active April 9, 2017 12:28
WG1800HP2 を再起動するスクリプト (user と password はルータのものを入力すること)
#!/bin/bash
ROUTER_IP='xxx.xxx.xxx.xxx'
HTML=`curl -u user:password -v "http://${ROUTER_IP}/index.cgi/reboot_main"`
SESSION_ID=`echo "${HTML}" | grep SESSION_ID| head -1 | sed -e "s/.*value='\(.*\)'.*$/\1/"`
curl -u user:password -v -o /dev/null "http://${ROUTER_IP}/index.cgi/reboot_main_set" --data "UPDATE_BUTTON=Reboot&SESSION_ID=${SESSION_ID}"
@gonzoooooo
gonzoooooo / cVimrc
Last active December 28, 2017 01:01
let mapleader = ","
let hintcharacters = "abcdefghjkmnopqrstuvwxyz"
let locale = "jp"
command g tabnew google
unmap s
map ; :
map <C-d> scrollPageDown
map <C-b> scrollFullPageUp