Skip to content

Instantly share code, notes, and snippets.

View RayanFar's full-sized avatar
🐐

RayanFar RayanFar

🐐
View GitHub Profile
@RayanFar
RayanFar / docker-compose.yml
Created September 9, 2023 19:16
mysql docker compose file
version: '3'
services:
database:
image: mysql
container_name: database.dev
command: mysqld --user=root --verbose
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: "test"
@RayanFar
RayanFar / TestMic.java
Created November 12, 2017 01:45
Java example for capturing and playing data from microphone
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.TargetDataLine;
public class TestMic {
public static void main(String[] args) {
AudioFormat format = new AudioFormat(44100, 16, 2, true, true);
public static String path(Class clazz) {
try {
File tmp = new File(clazz.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
String ext = tmp.getName();
if (ext.contains(".jar")) {
String p = tmp.toString();
p = p.substring(0, p.lastIndexOf(File.separator));
return p + File.separator;
float dis = rack2.getLocalTranslation().distance(socket.getLocalTranslation());
System.out.println("distance is => " + dis);
@RayanFar
RayanFar / classLoader.java
Last active May 19, 2016 19:59
class loader code
try {
URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader();
MyClassLoader l = new MyClassLoader(loader.getURLs());
l.addURL(new URL("file:C:\\Users\\yn\\Documents\\NetBeansProjects\\app\\dist\\app.jar"));
Class c = l.loadClass("app.App");
Object c1 = c.newInstance();
Method print = c.getMethod("print", null);
print.invoke(c1);
<useStyles filename="nifty-default-styles.xml" />
<useControls filename="nifty-default-controls.xml" />
@RayanFar
RayanFar / VLCJ in JMonkeyEngine
Created May 6, 2016 10:50
An example of how to draw a video using VLCJ onto a texture using JMonkeyEngine
import com.jme3.texture.Image;
import com.jme3.texture.Texture2D;
import com.jme3.texture.plugins.AWTLoader;
import java.awt.GraphicsEnvironment;
import java.awt.image.BufferedImage;
import uk.co.caprica.vlcj.component.DirectMediaPlayerComponent;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;
import uk.co.caprica.vlcj.player.direct.BufferFormat;
import uk.co.caprica.vlcj.player.direct.BufferFormatCallback;
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tools.camera;
import com.jme3.asset.AssetManager;
import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter;
import com.jme3.input.ChaseCamera;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tools;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tools;
import com.jme3.scene.Spatial;
/**