Skip to content

Instantly share code, notes, and snippets.

@akkijp
akkijp / mcat.c
Last active October 22, 2015 18:05
catコマンドを作る! linuxのファイルディスクリプタを使って、ファイルから端末へ出力する
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define BUFFER_SIZE 2048
static void die(const char *s){
@akkijp
akkijp / mcat.c
Last active October 22, 2015 18:05
catコマンドを作る! stdio版
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
int i;
if(argc < 2){
fprintf(stderr, "%s: file name not given\n", argv[0]);
exit(1);
}
@akkijp
akkijp / main.go
Created October 25, 2015 12:06
rbgをhexに相互変換する。golang
package main
import "fmt"
func main() {
fmt.Println(dec2hex(256, 4))
fmt.Println(rgb2int(256, 256, 256))
fmt.Println(int2rgb(0))
}
@akkijp
akkijp / main.c
Created October 26, 2015 11:44
c言語で正規表現で検索を行う
#include <stdio.h>
#include <regex.h>
void put_n_char(const char *s, regoff_t so, regoff_t eo)
{
const char * const ep = s + eo;
for(s += so; s != ep; s++) putchar(*s);
}
@akkijp
akkijp / README.md
Last active October 29, 2015 16:35
jQueryを使ったいろいろなエフェクト あれそれ

jQueryを使ったいろいろなエフェクト あれそれ

クラス名「slide_page_handler」がクリックされた時に、 ページ全体が横にスライドするエフェクトを追加する。

$("body > *").wrapAll('<div id="slide_page_wrapper" style="width:100%"></div>');
$('.slide_page_handler').click(function(){
  var pass = $(this).attr("href");
 $('#slide_page_wrapper').animate({marginLeft: '-='+$(window).width()+'px'},300,function(){
@akkijp
akkijp / Vagrantfile
Last active November 2, 2015 03:11
aws をmacから起動するvagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "dummy"
config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
@akkijp
akkijp / index.html
Created November 3, 2015 11:59
AngularJS の基本
<!DOCTYPE html>
<html lang="ja" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script>
angular.module("myApp", [])
.controller("MyController", function($scope){
$scope.mes = "こんにちわ、AngularJS!"
@akkijp
akkijp / centerPlacement.js
Last active November 4, 2015 08:15
windowの幅を狭くしたときに、window positionが中心になりながら狭くなっていくスクリプト
$(function(){
var $window = $(window),
$document = $(document);
$(window).on('resize', function(){
var wwidth = $window.width(),
dwidth = $document.width();
(wwidth < dwidth) && $document.scrollLeft( (dwidth - wwidth)/2 )
});
$(window).trigger('resize');
});
@akkijp
akkijp / index.html
Created November 4, 2015 06:09
Webページでタブを使うときのjQuery の一例
<!DOCTYPE html>
<html lang="ja">
<head>
<title>index.html</title>
<script type="text/javascript" src="./js/index.js"></script>
</head>
<body>
<header>
<div id="nav">
<ul class="global_nav">
@akkijp
akkijp / playbook.yml
Created November 8, 2015 12:21
ansible playbook.yml
- hosts: all
sudo: yes
vars:
username: webmaster
tasks:
- name: add a new user
user: name={{username}} state=absent
- name: upgrade all packages
yum: name=* state=latest
- name: install apache