Skip to content

Instantly share code, notes, and snippets.

@ramazanpolat
ramazanpolat / chooseWithChance.cs
Last active December 9, 2017 21:40
chooseWithChance.cs - Choose a random member of a set with a given chance of selection.
public static Random random = new Random(DateTime.Now.Millisecond);
public int chooseWithChance(params int[] args)
{
/*
* This method takes number of chances and randomly chooses
* one of them considering their chance to be choosen.
* e.g.
* chooseWithChance(1,99) will most probably (%99) return 1 since index of 99 is 1
* chooseWithChance(99,1) will most probably (%99) return 0 since index of 99 is 0
* chooseWithChance(0,100) will always return 1.
/* ----------------------------------
Minimal Theme for prettyPhoto lightbox
http://tutorialspage.com/pretty-photo-minimal-theme-a-pure-css-prettyphoto-simple-theme
----------------------------------- */
div.minimal { overflow: hidden; }
div.minimal .pp_gallery li.default a, div.minimal .pp_next, div.minimal a.pp_previous { background: none; } /* Cancel bg load */
div.minimal .pp_top, div.minimal .pp_top .pp_middle, div.minimal .pp_top .pp_left, div.minimal .pp_top .pp_right, div.minimal .pp_bottom, div.minimal .pp_bottom .pp_left, div.minimal .pp_bottom .pp_middle, div.minimal .pp_bottom .pp_right { height: 13px; display: none; }
div.minimal .pp_content_container .pp_left { padding-left: 13px; }
div.minimal .pp_content_container .pp_right { padding-right: 13px; }
div.minimal .pp_content { background-color: #fff; margin-bottom: -36px; }
@wliao008
wliao008 / add-item-to-list-dynamodb.go
Created January 15, 2018 03:27
How to add item to a dynamodb list with golang
/*
Took me a while to figure this out, this should never be so difficult IMHO. The dynamodb api could use more examples in its doc.
The documentation for doing this is scattered in a few places:
1. dynamodb api doc for golang: https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/
2. the Update Expression: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html
The structs belowed are abbreviated for the sake of the demo: adding a string to the questions slice in the dynamodb table.
@Arakade
Arakade / PhysXCCDEditorHelper.cs
Created December 22, 2018 14:29
Unity3D 2018.3 Editor script to find PhysX CCD problems
////////////////////////////////////////
// Find PhysX components that will trigger the Unity 2018 complaint about
// kinematic with Continuous Collision Detection:
//
// ERROR: [Physics.PhysX] RigidBody::setRigidBodyFlag: kinematic bodies with CCD enabled are not supported! CCD will be ignored.
//
// Use the script to find troublesome components in the scene or in the project
// then manually change them to a valid value, likely ContinuousSpeculative
//
// See https://docs.unity3d.com/ScriptReference/CollisionDetectionMode.ContinuousSpeculative.html