Skip to content

Instantly share code, notes, and snippets.

View michalczukm's full-sized avatar

Michał Michalczuk michalczukm

View GitHub Profile
@michalczukm
michalczukm / testfix
Created April 17, 2014 15:16
TestFixture R# template
[NUnit.Framework.TestFixtureAttribute]
public class $TESTCLASSNAME$
{
[NUnit.Framework.SetUpAttribute]
public void SetUp()
{
}
[NUnit.Framework.TestAttribute]
@michalczukm
michalczukm / jQuery extention
Created April 28, 2014 21:29
jQuery case insensitive search extension
$.expr[":"].ContainsCaseInsensitive = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
@michalczukm
michalczukm / PasswordHashService elements
Last active August 29, 2015 14:00
Fragment of code from [https://crackstation.net/hashing-security.htm#aspsourcecode] In compare with orginal methods: I removed hash alhorithm from hash string
function create_hash($password)
{
// format: algorithm:iterations:salt:hash
$salt = mcrypt_create_iv(PBKDF2_SALT_BYTE_SIZE, MCRYPT_DEV_URANDOM);
$encoded_salt = base64_encode($salt);
return PBKDF2_ITERATIONS . ":" . $encoded_salt . ":" .
base64_encode($this->pbkdf2(
PBKDF2_HASH_ALGORITHM,
$password,
$salt,
@michalczukm
michalczukm / gist:cac20e0902d628165154
Created November 4, 2014 14:50
Fancy search for commit in Git
git rev-list --all --grep="\.js" -v --oneline
// f.e. we found 8fe3195
git show 8fe3195 --name-only
@michalczukm
michalczukm / knockout-chosen.js
Last active August 29, 2015 14:18 — forked from tomazy/knockout-chosen.js
For TypeScript
ko.bindingHandlers.chosen = {
init: (element, valueAccessor, allBindings, viewModel, bindingContext) => {
var $element = $(element);
var options = ko.unwrap(valueAccessor());
if (typeof options === 'object')
$element.chosen(options);
['options', 'selectedOptions'].forEach(propName => {
if ((<any>allBindings).has(propName)) {
@michalczukm
michalczukm / test_template
Created May 4, 2015 10:56
Test (NUnit) R# template
[Test]
public void Should$TestName$()
{
// arrange
// act
var actual = _sut.$END$
// assert
actual.Should().Be(expected);
@michalczukm
michalczukm / TestHelper
Last active August 29, 2015 14:20
Act Test method ignoring not exceptions of type
public static class TestHelper
{
public static void ActIgnoringExceptions<TException>(Action act) where TException : Exception
{
try
{
act.Invoke();
}
catch (TException ex)
{
@michalczukm
michalczukm / FormUtils
Created May 15, 2015 23:47
JS prevent submit form on enter
// usage
FormUtils.preventSubmitOnEnter($('#add_segment_form'));
FormUtils = {
init: function(){},
preventSubmitOnEnter: function($form){
$form.on("keyup keypress", function(e) {
var code = e.keyCode || e.which;

Oops! I accidentally deleted a local git branch, and I haven't pushed it to a remote server yet. The branch has several important commits, and it hasn't been merged with any other branches yet. How do I find the missing branch?

1. Create a list of all dangling or unreachable commits.

$ git fsck --full --no-reflogs --unreachable --lost-found
unreachable tree 4a407b1b09e0d8a16be70aa1547332432a698e18
unreachable tree 5040d8cf08c78119e66b9a3f8c4b61a240229259
unreachable tree 60c0ce61b040f5e604850f747f525e88043dae12
unreachable tree f080522d06b9853a2f18eeeb898724da4af7aed9
@michalczukm
michalczukm / .gitignore
Created August 5, 2015 08:58
WPF projects .gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/