Skip to content

Instantly share code, notes, and snippets.

View casarock's full-sized avatar

Carsten Sandtner casarock

View GitHub Profile
<html>
<head>
<title>Snake</title>
</head>
<body>
<!-- Lets make a simple snake game -->
<canvas id="canvas" width="450" height="450"></canvas>
</body>
<script type="text/javascript">
$('.mym-tb-tabs .mym-tb-choose', this).click(function() {
$(this).parent().toggleClass('mym-tb-open');
});
<html>
<head>
<title>Maze</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="mazegenerator.js"></script>
<style type="text/css">
#maze {
border-collapse: collapse;
}
@casarock
casarock / gist:9078481
Last active August 29, 2015 13:56
load dynamic tilemaps.
var demo = {
getTiledMapDefinition: function(tilemap, layerName, tileWidth, tileHeight, tileImageName, imgWidth, imgHeight) {
var tileData = this.tileMapToArray(tilemap),
tilemapHeight = tilemap.length,
tilemapWidth = tilemap[0].length,
tileLayer = this.tiledLayerBlueprint(tileData, tilemapHeight, tilemapWidth, layerName),
tileImage = this.tiledTilesBlueprint(imgWidth, imgHeight, tileImageName, tileWidth, tileHeight);
return this.tiledBlueprint(tileLayer, tileImage);
Acc.Game = function (game) {
this.game = game;
};
Acc.Game.prototype = {
create: function () {
this.MAX_VELX = 125;
<link href="../core-animated-pages/core-animated-pages.html" rel="import">
<link href="../core-animated-pages/transitions/hero-transition.html" rel="import">
<link href="../core-animated-pages/transitions/cross-fade.html" rel="import">
<link href="../core-animated-pages/transitions/slide-down.html" rel="import">
<link href="../core-animated-pages/transitions/slide-up.html" rel="import">
<link href="../core-animated-pages/transitions/tile-cascade.html" rel="import">
<link href="../core-field/core-field.html" rel="import">
<link href="../core-icon/core-icon.html" rel="import">
<link href="../core-input/core-input.html" rel="import">
<link href="../core-icons/core-icons.html" rel="import">
@casarock
casarock / ClockView.swift
Created February 6, 2016 16:30
Custom Timer View in Swift
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
class ClockView: UIView {
private var shapeLayer = CAShapeLayer()
private var countDownTimer = NSTimer()
private var timerValue = 900
@casarock
casarock / cleaning.py
Last active May 19, 2020 07:18
Clean bot data
def get_clean_data(self):
df = pd.read_csv(self.csv_url)
df = df.drop(columns=['Lat', 'Long'])
df_group = df.groupby(['Country/Region'])
germany = df_group.get_group('Germany')
overall = df.agg(['sum'])
germany = germany.agg(['sum'])
@casarock
casarock / cleaning.py
Created May 19, 2020 08:06
Cleaning part 2
def clean_Data(self, data_frame, country, drop_columns):
cleaned_data_frame = data_frame.drop(columns=drop_columns)
cleaned_data_frame = cleaned_data_frame.T
cleaned_data_frame['related'] = (100/self.population[country]) * cleaned_data_frame['sum']
return cleaned_data_frame
@casarock
casarock / calculate.py
Created May 19, 2020 08:09
Calculating interesting stuff
def get_actual_infected(self):
germany_changed = self.germany.tail(2)['sum'][1] - self.germany.tail(2)['sum'][0]
overall_changed = self.overall.tail(2)['sum'][1] - self.overall.tail(2)['sum'][0]
germany = '+' if germany_changed > 0 else '-'
overall = '+' if overall_changed > 0 else '-'
germany += str(germany_changed)
overall += str(overall_changed)