Skip to content

Instantly share code, notes, and snippets.

View pralhadstha's full-sized avatar

Pralhad Kumar Shrestha pralhadstha

View GitHub Profile
@pralhadstha
pralhadstha / early_stopping.py
Created August 16, 2020 03:00 — forked from stefanonardo/early_stopping.py
Early Stopping PyTorch
class EarlyStopping(object):
def __init__(self, mode='min', min_delta=0, patience=10, percentage=False):
self.mode = mode
self.min_delta = min_delta
self.patience = patience
self.best = None
self.num_bad_epochs = 0
self.is_better = None
self._init_is_better(mode, min_delta, percentage)
@pralhadstha
pralhadstha / earlystopping.py
Created July 20, 2020 10:24 — forked from ryanpeach/earlystopping.py
A Python 3 implementation of the early stopping algorithm described in the Deep Learning book by Ian Goodfellow. Untested, needs basic syntax correction.
""" Python 3 implementation of Deep Learning book early stop algorithm.
@book{Goodfellow-et-al-2016,
title={Deep Learning},
author={Ian Goodfellow and Yoshua Bengio and Aaron Courville},
publisher={MIT Press},
note={\url{http://www.deeplearningbook.org}},
year={2016}
}
"""
@pralhadstha
pralhadstha / laravel-mongodb-sentinel
Created August 7, 2017 06:45 — forked from Bodom78/laravel-mongodb-sentinel
Use the Sentinel 2.x authentication package with Laravel 5.1 and MongoDB
Work in Progress: More testing to be done.
At a glance Authentication, Activation, Throttle, Groups & Permissions seem to
be working.
Downside: Copy and modify files.
Upside: Not really much work to get it up and running.
Assumes you have Laravel 5.1, jenssegers/laravel-mongodb + session addon set up
and your app is namespaced to App/
@pralhadstha
pralhadstha / RouteLinkProviderService.ts
Created December 14, 2016 03:58 — forked from klinki/RouteLinkProviderService.ts
RouteLinkProviderService - service which maps component into its route
import {Routes, Route} from "@angular/router";
import {Injectable} from "@angular/core";
@Injectable()
export class RouteLinkProviderService {
protected routes: Routes;
protected routesByComponents = new Map<any, any>();
constructor(routes: Routes) {
@pralhadstha
pralhadstha / MailGunBasicSendMail.java
Created August 30, 2016 02:53 — forked from hpsaturn/MailGunBasicSendMail.java
Send Mail basic implementation via MailGun API and Retrofit for Android
import android.util.Base64;
import com.google.gson.Gson;
import com.hpsaturn.robotsanta.Config;
import com.hpsaturn.robotsanta.models.MailGunResponse;
import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.converter.GsonConverter;
import retrofit.http.Field;
gulpfile.js
const elixir = require('laravel-elixir');
require('laravel-elixir-vue');
require('laravel-elixir-vueify');
elixir.config.sourcemaps = false;
elixir(mix => {
@pralhadstha
pralhadstha / php-cs-fixer
Created August 12, 2016 10:17 — forked from mpalourdio/php-cs-fixer
@fabpot php-cs-fixer config for PhpStorm
parameters
--level=psr2 --verbose fix $FileDir$/$FileName$
working directory
$ProjectFileDir$
@pralhadstha
pralhadstha / 4chan.py
Created February 11, 2016 10:48
4chan images downloader
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016, Alexis Nootens <me@axn.io>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
@pralhadstha
pralhadstha / eloquent.md
Created February 11, 2016 10:47 — forked from msurguy/eloquent.md
Laravel 4 Eloquent Cheat Sheet.

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@pralhadstha
pralhadstha / extract_realm_database_android.sh
Created February 6, 2016 17:11 — forked from medyo/extract_realm_database_android.sh
Shell script that exports Realm database from a connected device
#!/bin/sh
ADB_PATH="/Users/medyo/Library/Android/sdk/platform-tools"
PACKAGE_NAME="com.mobiacube.elbotola.debug"
DB_NAME="default.realm"
DESTINATION_PATH="/Users/Medyo/Desktop/"
NOT_PRESENT="List of devices attached"
ADB_FOUND=`${ADB_PATH}/adb devices | tail -2 | head -1 | cut -f 1 | sed 's/ *$//g'`
if [[ ${ADB_FOUND} == ${NOT_PRESENT} ]]; then
echo "Make sure a device is connected"
else