Skip to content

Instantly share code, notes, and snippets.

View joladev's full-sized avatar

Johanna Larsson joladev

View GitHub Profile
@joladev
joladev / NewInheritance.cs
Last active December 15, 2015 07:09
Inheritance and new keyword
using System;
class Program
{
public class A
{
public void print()
{
Console.WriteLine("A");
}
}
function april {
param([Switch] $Undo)
$customCssPath = "C:/Users/$env:username/AppData/Local/Google/Chrome/User Data/Default/User StyleSheets/Custom.css"
$customCss = "body { -webkit-transform: rotate(180deg); }"
if ($Undo)
{
copy "$customCssPath.backup" $customCssPath
}
CUSTOM_CSS_PATH="/Users/$(whoami)/Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css"
CUSTOM_CSS="body { -webkit-transform: rotate(180deg); }"
if [ "$1" = "--undo" ]
then
mv "$CUSTOM_CSS_PATH.backup" "$CUSTOM_CSS_PATH"
else
cp "$CUSTOM_CSS_PATH" "$CUSTOM_CSS_PATH.backup"
echo $CUSTOM_CSS >> "$CUSTOM_CSS_PATH"
fi
// class definition
public class JavaClass {
// this is a field, also known as class variable
private String variableName;
// they can also be public, but this is not recommended!
public String badVariable;
// you can initialize the value in the same step
@joladev
joladev / insertjquery.js
Created June 28, 2013 14:43
Insert jQuery into current page
// Insert jQuery into current page
var s = document.createElement("script");
s.src = "//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js";
document.getElementsByTagName("head")[0].appendChild(s);
@joladev
joladev / gist:5933011
Last active December 19, 2015 09:29 — forked from anonymous/gist:5933010
public int LostTrainees(int a, int b, int c)
{
int lives = 3;
int doorsOpened = 0;
while (true)
{
var result = OpenDoor(b);
var weapon = GetWeapon();
switch (result)
{
var intervalId = setInterval(function () {
if (condition) {
return;
} else {
clearInterval(intervalId);
}
alert("I finished");
REM Install Chocolatey
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
REM Install Tools
cinst Firefox &&
cinst firefoxaurora &&
cinst ulsviewer &&
cinst GoogleChrome &&
cinst GoogleChrome.Canary &&
cinst opera &&
@joladev
joladev / defer.js
Last active December 21, 2015 03:19
var defer = function () {
var value,
resolution,
handlers = {};
var fulfill = function () {
if (resolution) {
var handler = handlers[resolution];
if (handler) {
handler();
@joladev
joladev / randomstring.rs
Last active December 24, 2015 13:39
Random string generation in Rust (for Weasel)
use std::rand;
use std::rand::Rng;
use std::str;
static TARGET: &'static str = "methinks it is like a weasel";
static ALPHABET: [char, ..26] = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];