Skip to content

Instantly share code, notes, and snippets.

@yukari-n
yukari-n / banner.php
Created January 4, 2020 06:48
ランダムバナー
<?php
$image = array(
'banner1.jpg',
'banner2.jpg',
'banner3.jpg'
);
$image = $image[rand(0, count($image)-1)];
if (file_exists($image)){
header('Content-Type: image/jpeg');
readfile($image);
@yukari-n
yukari-n / curl.sh
Created June 1, 2019 10:31
連続アクセスしたいときに使うやつ(悪用はやめましょう)
#!/bin/bash
# $1 = 叩く回数
# $2 = "叩きたいURL"
# 確実に叩きたいのでステータスコードが200じゃなかった分は数を引いています。
# 落ちてるサーバーに何回もアクセスしてもしょうがないけど今回必要な数だと20秒もあれば終わってしまうので途中で止めなくても良いかなという感じ。
if [ $# -ne 2 ]; then
echo "引数足りてないです"
elif [ $1 -gt 150 ]; then
echo "悪用はやめましょう"
@yukari-n
yukari-n / sort.scala
Created April 11, 2019 09:45
Scalaでsort
val row1 = (11,"asdf","hoge")
val row2 = (2,"basdf","hoge")
val csv = Seq(row1,row2)
csv.sortBy(_._1)
// res0: Seq[(Int, String, String)] = List((2,basdf,hoge), (11,asdf,hoge))
@yukari-n
yukari-n / LinkcardShortcode.php
Last active July 12, 2018 14:44
Gravのカスタムショートコードでリンクカードを作る。
<?php
namespace Grav\Plugin\Shortcodes;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use Thunder\Shortcode\Shortcode\ProcessedShortcode;
class LinkcardShortcode extends Shortcode {
public function init() {
$this->shortcode->getHandlers()->add('site', function(ProcessedShortcode $sc) {
$url = $sc->getParameter('url');
@yukari-n
yukari-n / 0_reuse_code.js
Created May 19, 2017 05:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@yukari-n
yukari-n / lib_google_related.php
Last active February 12, 2017 08:34
関連記事表示。_は/に読み替え。解説という名のメモ https://yukari-n.gitbooks.io/wordpress/content/related-posts/
@yukari-n
yukari-n / lib_css.php
Last active January 6, 2017 01:28
サイトのコード(一部)。_は/に読み替え。テストサイトは間に合いませんでした。稼働しているサイトは秘密。
<?php
// CSS登録
function register_style(){
wp_register_style('bootstrap','http://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css');
wp_register_style('cc','/css/cc.css');
wp_register_style('sawarabi','https://fonts.googleapis.com/earlyaccess/sawarabimincho.css');
wp_register_style('ccommons','https://cdn.jsdelivr.net/cc-icons/1.2.1/css/cc-icons.min.css'); //'https://cdnjs.cloudflare.com/ajax/libs/cc-icons/1.2.1/css/cc-icons.min.css'
}
function add_stylesheet(){
register_style();