Skip to content

Instantly share code, notes, and snippets.

View pmudry's full-sized avatar

Pierre-André Mudry pmudry

  • Filière ISC, HES-SO Valais-Wallis
  • Switzerland
View GitHub Profile
@pmudry
pmudry / gist:2ce9751e69e6845fd08e
Created February 6, 2014 09:07
Stars in GLSL
vec3 p = vec3(vTexCoord / 4., 0) + vec3(1., -1.3, 0.);
p += .2 * vec3(sin(time / 16.), sin(time / 12.), sin(time / 128.));
//Thanks to http://glsl.heroku.com/e#6904.0
vec2 seed = p.xy * 4.0;
seed = floor(seed * resolution.x);
vec3 rnd = nrand3( seed );
vec4 starcolor = vec4(pow(rnd.y,20.0));
//Second Layer
@pmudry
pmudry / gist:9481319
Last active August 29, 2015 13:57
Latexing shortcuts for Sublime text
ctrl-l + ctrl-n --> create a new environment
ctrl-l + ctrl-e --> create a new environment, with the name being the word you just typed
shift-enter --> creates a new line in an item or enumeration list
ctrl-l + ctrl-p --> shows the commands
@pmudry
pmudry / gist:34b2bd4381ebf7167dbf
Last active January 4, 2016 21:34
JSON parse using Scala standard parser
import scala.util.parsing.json._
val result = JSON.parseFull("""
{"name": "Naoki", "lang": ["Java", "Scala"]}
""")
result match {
case Some(e) => println(e) // => Map(name -> Naoki, lang -> List(Java, Scala))
case None => println("Failed.")
}
class MidiLoader {
/**
*loads a midi file from disk and stores all notes in a nested Array List, using the Helper class "Note"
* needs some cleanup though
*/
ArrayList<ArrayList<Note>> tracks;
long maxTicks = 0;
final boolean DO_PRINT = false;
MidiLoader(String fileName) {
<style>
/* customizable snowflake styling */
.snowflake {
color: #fff;
font-size: 1em;
font-family: Arial;
text-shadow: 0 0 1px #000;
}
@-webkit-keyframes snowflakes-fall{0%{top:-10%}100%{top:100%}}@-webkit-keyframes snowflakes-shake{0%{-webkit-transform:translateX(0px);transform:translateX(0px)}50%{-webkit-transform:translateX(80px);transform:translateX(80px)}100%{-webkit-transform:translateX(0px);transform:translateX(0px)}}@keyframes snowflakes-fall{0%{top:-10%}100%{top:100%}}@keyframes snowflakes-shake{0%{transform:translateX(0px)}50%{transform:translateX(80px)}100%{transform:translateX(0px)}}.snowflake{position:fixed;top:-10%;z-index:9999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default;-webkit-animation-name:snowflakes-fall,snowflakes-shake;-webkit-animation-duration:10s,3s;-webkit-animation-timing-function:linear,ease-in-out;-webkit-animation-iteration-count:infinite,infinite;-webkit-animation-play-state:running,running;animation-name:snowflake
@pmudry
pmudry / convert_all_to_xvid.bat
Created January 16, 2016 22:02
Batch converts (in windows) using FFMEG a whole directory to XVID (for crappy car player)
for %%a in ("*.mkv") do ffmpeg -i "%%a" -c:v libxvid -qscale:v 2 "newfiles\%%~na.avi"
pause
@pmudry
pmudry / sublime_textttt
Created January 26, 2016 08:54
Adding a \texttt command to Sublime text
Add this to Packages/User/test-snippet.sublime-snippet
<snippet>
<content><![CDATA[
\texttt{$SELECTION}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
@pmudry
pmudry / ww_android.java
Last active January 27, 2016 12:37
ww_android
public int getWidth(){
return view.getContext().getResources().getDisplayMetrics().widthPixels;
}
find . -name '*.h' -type f -exec grep -H 'WHAT YOU ARE LOOKING FOR' {} \;
@pmudry
pmudry / gist:814278d11d1d6909ab6bdee0b1cace63
Last active May 29, 2018 13:32
Input multiplexer with stage
stage = new Stage();
InputMultiplexer multiplexer = new InputMultiplexer();
multiplexer.addProcessor(stage);
multiplexer.addProcessor(Gdx.input.getInputProcessor());
Gdx.input.setInputProcessor(multiplexer);
// To be put inside each class extending `RenderingScreen`.
// In addition, in the key processing methods, should delegate to the rendering screen themselves
public void onKeyDown(int keycode) {