Skip to content

Instantly share code, notes, and snippets.

View curegit's full-sized avatar

curegit curegit

View GitHub Profile
@curegit
curegit / basic_auth_ssl.htaccess
Created August 7, 2018 15:32
Require SSL for basic auth
ErrorDocument 401 "Unauthorized Access"
RewriteEngine off
SSLRequireSSL
AuthUserFile "_________.htpasswd"
AuthName "Authorization Required"
AuthType BASIC
require valid-user
order deny,allow
@curegit
curegit / redirect_to_ssl.htaccess
Last active March 16, 2019 14:06
SSLへリダイレクト
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@curegit
curegit / tooltip.cs
Last active September 5, 2020 07:15
インスペクター拡張で tooltip 表示
public override void OnInspectorGUI()
{
Target.testFloat = EditorGUILayout.FloatField(new GUIContent("Test Float", "Here is a tooltip"), Target.testFloat);
}
@curegit
curegit / modulos.cs
Last active September 5, 2020 07:16
C# 3種の剰余演算
using System;
public static class MyIntegerExtensions
{
public static int TruncatedMod(this int dividend, int divisor)
{
return dividend % divisor;
}
public static int FlooredMod(this int dividend, int divisor)
@curegit
curegit / fizzbuzz.lisp
Created April 2, 2019 04:43
Common Lisp で FizzBuzz
(defun fizzbuzz (n)
(loop for i from 1 to n
do (cond ((equal (mod i 15) 0) (format t "~%fizzbuzz"))
((equal (mod i 5) 0) (format t "~%buzz"))
((equal (mod i 3) 0) (format t "~%fizz"))
(t (print i)))))
(defun fizzbuzz-main ()
(fizzbuzz 100))
@curegit
curegit / qrcode.cgi
Last active February 23, 2021 12:58
QRコードを出すPerl CGI
#!/usr/bin/perl
use CGI;
use GD::Barcode::QRcode;
binmode(STDOUT);
my $cgi = new CGI;
my $string = $cgi->param("string");
@curegit
curegit / redirect_to_no_www.htaccess
Created June 20, 2019 12:21
wwwなしへリダイレクト
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.jp$
RewriteRule ^(.*)$ https://example.jp%{REQUEST_URI} [R=301,L]
@curegit
curegit / contextmenu.js
Last active November 17, 2024 17:17
右クリックの禁止を無効にするブックマークレット
javascript: document.addEventListener("contextmenu", function (e) { e.stopPropagation(); }, true);
@curegit
curegit / middle.py
Last active September 5, 2020 07:17
min max で3つの値の真ん中を求める
def mid(a, b, c):
return min(min(max(a, b), max(b, c)), max(c, a))
@curegit
curegit / downsafe.py
Created June 17, 2020 07:37
Safebooru から画像をスクレイピングするスクリプト
import sys
from os import makedirs
from itertools import count
from os.path import basename
from xml.etree import ElementTree
from urllib.parse import urlencode
from urllib.request import urlopen, urlretrieve
for tag in sys.argv[1:]:
dir = basename(tag)