Skip to content

Instantly share code, notes, and snippets.

View mythosil's full-sized avatar

Akito Tabira mythosil

View GitHub Profile
@mythosil
mythosil / dna_complement.c
Created January 24, 2019 15:03
DNA complement (A<>T, G<>C, N<>N) with only bit operations.
#include <stdio.h>
char dna_complement(char dna)
{
dna ^= 0x15;
dna ^= (dna & 0x02) << 3;
dna ^= (dna & 0x02) >> 1;
dna ^= (dna & 0x08) >> 1;
return dna;
}
@mythosil
mythosil / ShareFBMessenger.java
Created March 29, 2016 14:42
How to share messages via Intent
public void fbIntentShare() {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setPackage("com.facebook.orca"); // facebook messenger
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "Yahoo! JAPAN\n http://yahoo.co.jp");
startActivityForResult(intent, 1);
}
@mythosil
mythosil / weld-with-javase
Last active August 29, 2015 14:07
Use Weld with Java SE
Sample Application using Weld with Java SE
@mythosil
mythosil / pom.xml
Created July 10, 2014 16:25
pom.xml template for wildfly-javaee7 project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mythosil</groupId>
<artifactId>wildfly-template</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>wildfly-template</name>
import soundcloud
client = soundcloud.Client(client_id=CLIENT_ID)
tracks = client.get('/tracks', q='search query', genres='funk', bpm={ 'from': 110, 'to': 130 })
print vars(tracks)
@mythosil
mythosil / http_server.sh
Created October 9, 2013 15:35
start simple http server serve static files in the current directory
#!/bin/sh
function http_server() {
local PORT=8888
if [ $# -ne 0 ]; then
expr $1 + 1 > /dev/null 2>&1
if [ $? -lt 2 ]; then
PORT=$1
else
echo "Usage: http_server <port>" return 1
@mythosil
mythosil / FQDNAnnotationBeanNameGenerator.java
Created September 6, 2013 02:42
bean-name-generator for annotated classes. generates FQDN bean name.
package com.mythosil.spring.context;
import java.beans.Introspector;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
public class FQDNAnnotationBeanNameGenerator extends AnnotationBeanNameGenerator {
/**
* Derive a bean name from the given bean definition.
@mythosil
mythosil / AnnotationSample.java
Created October 26, 2012 16:04
original annotation sample
/**
*
* $ javac AnnotationSample.java -Xlint:unchecked
* $ java AnnotationSample
*
*/
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@mythosil
mythosil / sbml.groovy
Created October 13, 2012 12:49
sbml simulation with groovy
/* settings */
def filename = './mapk.xml'
def duration = 4000.0
def dt = 0.1
/************/
def doc = new XmlParser().parse(filename)
def model = doc.model[0]
def species = [:]
def parameters = [:]
@mythosil
mythosil / SwingTest.java
Created February 21, 2012 15:24
Swing sample
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
class SwingTest {
public static void main(String args[]) {
JFrame window = new JFrame("title");
JButton button = new JButton("button");
button.addActionListener(new ActionListener() {