Skip to content

Instantly share code, notes, and snippets.

@totem3
totem3 / gist:460123c290a835f55ea20c7ee0e882ab
Created August 15, 2020 05:06
asanのheap buffer overflowになる
#include <iostream>
using std::cout;
using std::endl;
class Solution {
public:
int islandPerimeter(vector<vector<int>>& grid) {
int ans=0;
for (int i=0;i<grid.size();i++) {
for (int j=0;j<grid[i].size();j++) {
@totem3
totem3 / test.rs
Last active August 6, 2020 07:39
mapにするとうまくいかないやつがわかったとき
struct Nanika {
v: V,
}
struct V(u8);
impl V {
fn incr(&mut self) {
self.0 += 1
}
@totem3
totem3 / large_stack.rs
Created May 6, 2020 12:57
windowsとlinuxでstack overflowするサイズの比較
#![allow(unused)]
use std::fs::File;
use std::io::{self, Read, Write};
const SIZE: usize = 8000;
fn main() {
let stack = std::env::var("RUST_MIN_STACK").unwrap_or("nothing".to_string());
println!("RUST_MIN_STACK: {}", stack);
println!("allocate size: {}MB", SIZE * 1024 / 1024 / 1024);
@totem3
totem3 / large_stack.rs
Created May 6, 2020 12:57
windowsとlinuxでstack overflowするサイズの比較
#![allow(unused)]
use std::fs::File;
use std::io::{self, Read, Write};
const SIZE: usize = 8000;
fn main() {
let stack = std::env::var("RUST_MIN_STACK").unwrap_or("nothing".to_string());
println!("RUST_MIN_STACK: {}", stack);
println!("allocate size: {}MB", SIZE * 1024 / 1024 / 1024);
@totem3
totem3 / main.rs
Last active August 27, 2018 14:11
brainf*ck jit
extern crate libc;
use std::env;
use std::fs::{self, File};
use std::io::Read;
use std::mem;
use std::ops::{Index, IndexMut};
#[derive(Debug)]
pub struct Inst {
@totem3
totem3 / x.rs
Created January 24, 2018 21:30
fn is_foo(s: &str) -> bool {
s == "foo"
}
fn is_bar<S: PartialEq<str> + AsRef<str>>(s: &&S) -> bool {
s.as_ref() == "bar"
}
fn main() {
let v: Vec<String> = vec!["foo".to_owned()];
@totem3
totem3 / foo.c
Last active January 30, 2018 00:39
#include <stdio.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include "osfmk/mach/machine.h"
#include "EXTERNAL_HEADERS/mach-o/loader.h"
#include <string.h>
#include <assert.h>
int main()
This file has been truncated, but you can view the full file.
/rdsdbbin/mysql/bin/mysqld, Version: 5.6.27-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
# Time: 171108 20:00:00
# User@Host: root[root] @ [10.105.162.162] Id: 75015897
# Query_time: 0.138043 Lock_time: 0.000284 Rows_sent: 20 Rows_examined: 17457
use luccy_production;
SET timestamp=1510171200;
SELECT `articles`.`id` AS t0_r0, `articles`.`article_type` AS t0_r1, `articles`.`status` AS t0_r2, `articles`.`author_id` AS t0_r3, `articles`.`category_id` AS t0_r4, `articles`.`title` AS t0_r5, `articles`.`main_image_element_id` AS t0_r6, `articles`.`description` AS t0_r7, `articles`.`redirect_article_id` AS t0_r8, `articles`.`main_photo_position` AS t0_r9, `articles`.`advertiser` AS t0_r10, `articles`.`original_url` AS t0_r11, `articles`.`published_at` AS t0_r12, `articles`.`deleted_at` AS t0_r13, `articles`.`created_at` AS t0_r14, `articles`.`updated_at` AS t0_r15, `users`.`id` AS t1_r0, `users`.`uuid` AS t1_r1, `users

!SLIDE

今日のお題

ActionController

!SLIDE

  • ActionDispatch が dispatch する先
  • MVC の まさに C(まさに)
require "warden"
class App
def call(env)
env['warden'].authenticate!
[200, {'Content-Type' => 'text/plain'}, ['OK']]
end
end
Warden::Strategies.add(:password) do