Skip to content

Instantly share code, notes, and snippets.

@kawasima
kawasima / SafeRequestProcessor.java
Last active August 29, 2015 14:00
A workaround for CVE-2014-0114
package example;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServletWrapper;
import org.apache.struts.action.RequestProcessor;
import org.apache.struts.config.ModuleConfig;
import org.apache.struts.taglib.html.Constants;
package example;
import org.apache.commons.beanutils.expression.DefaultResolver;
public class SafeResolver extends DefaultResolver {
@Override
public String next(String expression) {
String property = super.next(expression);
if ("class".equalsIgnoreCase(property)) {
@drmalex07
drmalex07 / helloworld-win32-service.py
Created April 12, 2014 20:08
An example Windows service implemented with pywin32 wrappers. #python #windows-service #pywin32
import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
import time
import logging
logging.basicConfig(
filename = 'c:\\Temp\\hello-service.log',
@imaya
imaya / jser.md
Created March 17, 2014 02:00
JavaScript プログラマの職種は4種類くらいに分けるべき

はじめに

JavaScript を使っていると「JavaScript出来るの? jQuery / AngularJS / Node.js etc... で困ってるんだけどさー」みたいな話を振られることがあります。 そういった時に、自分は一般的なライブラリの使い方やフレームワークに対して大した知見も興味もないので、わざわざ説明するのも面倒なのでこうして文章にしておきます。(本当に届いて欲しい人に限って、こういう文章が届かないのはわかっていますが、文章を書くこと自体が気晴らしだと思って諦めます。)

「フロントエンドエンジニア」という言葉の汎用性

先ほどのような話は自分に限ったことではなく、たぶん経験のある人も多いでしょう。 振られた話が自分の分かる範囲、あるいは興味のあるものならばまだ良いのですが、そうでないことがあまりに多すぎます。 話を振られるだけならともかく「JavaScriptできるんでしょ? じゃあ jQuery つかったこのサービスのメンテしてほしいんだけどー」みたいに仕事として振られることもあり、そう言う時は脳みそ取り出して洗剤で洗った方が良いのでは、と思うことも多々あります。

@t-nissie
t-nissie / !HowToGist.md
Last active August 30, 2025 09:11
Gistの使い方のメモ

Gistの使い方のメモ

Gistを使い始めて気がついた点をメモした。 Gistはこのようなメモや短いコードをバージョン管理しながら公開するのに便利。

特にこのメモでは、画像を同一ディレクトリに置いて、 それGFMファイル内に挿入する方法を解説。

このメモにはgitコマンドの使い方の解説はない。 このメモは随時更新される予定。

import java.util.Random;
import sun.misc.Unsafe;
import sun.nio.ch.DirectBuffer;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
//Interfaces for working with excel
//this file allows me to not have a reference to excel in the project
//Adding a reference is to a specific version, these interfaces apply to all
//see Kenny Ker's blog http://weblogs.asp.net/kennykerr/archive/2008/12/16/Rtd7.aspx
@bsommardahl
bsommardahl / gist:8605208
Last active January 17, 2024 15:42
RTD Client in C#
public interface IRtdClient
{
object GetValue(params object[] args);
}
public class RtdClient : IRtdClient
{
readonly string _rtdProgId;
static IRtdServer _rtdServer;
@keijiro
keijiro / ScreenRecorder.cs
Last active January 26, 2022 05:01
Screen recording utility.
using UnityEngine;
using System.Collections;
public class ScreenRecorder : MonoBehaviour
{
public int framerate = 30;
public int superSize;
public bool autoRecord;
int frameCount;
@takawitter
takawitter / gist:5895868
Last active December 19, 2015 04:18
ThreadPoolExecutorに値を返すlambda(or closure)をsubmitしたい。submit(Callable<T> task)が呼ばれればOKなんだけど、ThreadPoolExecutorにはsubmit(Runnable task)も存在するので、普通にlambdaを渡すと曖昧性が解消できない。そのためCallable<T>を明示する必要があるが、その方法が言語によって違うって話。 ScalaとJythonとJRubyは直接やる方法が無さそうなので、ラッパークラスをかましてる。
/*
* tp は Executors.newCachedThreadPool 等を使って生成
*/
// Rhino(JavaScript)
tp.submit(new Callable({call: function(){ return 1;}}));
// Groovy
tp.submit({1} as Callable)