Skip to content

Instantly share code, notes, and snippets.

View ihatecsv's full-sized avatar
☢️
Totally tubular

Drake ihatecsv

☢️
Totally tubular
View GitHub Profile
@ihatecsv
ihatecsv / index.js
Created December 30, 2017 19:11
Proper way to preserve "this"?
class ExampleClass{
constructor(a){
this.a = a;
}
someMethod(){
const outerThis = this;
someOtherMethod(function(b){
outerThis.a = b;
});
}
@ihatecsv
ihatecsv / index.js
Created December 26, 2017 18:16
Best practice for JS classes?
//------------------------- Method 1
class TestClass1{
constructor(a){
this.a = a;
}
static someMethod(){
return new this(5);
}
@ihatecsv
ihatecsv / highlight.js
Created December 16, 2017 18:59
Highlight selected text matches on page (jQuery)
//Note:
//Requires jQuery! Also, you need to define a CSS class for .highlight
//Something like: .highlight{background-color: #ff96da;}
function getSelectionText() { //Thanks https://stackoverflow.com/a/5379408
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
@ihatecsv
ihatecsv / rv.js
Created December 2, 2017 23:54
Randomness visualizer
var dim = 256;
var offset = 5;
var randomSources = [
{
rBool: function(){
return Math.random() >= 0.5;
//return 1;
}
},
SSLCompression off
SSLProtocol All -SSLv2 -SSLv3
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLOpenSSLConfCmd DHParameters "/etc/ssl/certs/dhparam.pem"
<VirtualHost *:80>
ServerName dev.dom1.com
Redirect permanent / https://dev.dom1.com/
</VirtualHost>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
else{
System.out.println("Handled");
RadiationEventHandler.chunkList.put(chunk, new ArrayList<Point3D>());
int modCornerX = n*16;
int modCornerZ = m*16;
for(int i = modCornerX; i <= modCornerX+15; i++){
for(int k = modCornerZ; k <= modCornerZ+15; k++){
for(int j = 0; j <= 255; j++){
Block sourceBlock = player.worldObj.getBlock(i, j, k);
public boolean equals(RadChunk chunk){
if(this.x == chunk.x && this.z == chunk.z){
return true;
}
return false;
}
@ihatecsv
ihatecsv / snip.java
Created December 31, 2015 02:08
mapChunk
@SubscribeEvent(priority=EventPriority.LOWEST)
public void onChunkLoad(ChunkEvent.Load event) {
int chunkX = event.getChunk().xPosition;
int chunkZ = event.getChunk().zPosition;
int cornerX = chunkX*16;
int cornerZ = chunkZ*16;
//System.out.println("chunk at " + chunkX + ", " + chunkZ + " getting loaded");
//System.out.println("Boundries at " + cornerX + ", " + cornerZ);