Skip to content

Instantly share code, notes, and snippets.

View irsalshabirin's full-sized avatar
😊
:)

Irsal Shabirin irsalshabirin

😊
:)
  • 09:46 (UTC +07:00)
View GitHub Profile
@mrexclamation
mrexclamation / NPerGroup.php
Last active December 19, 2017 14:07
Enhanced version of https://softonsofa.com/tweaking-eloquent-relations-how-to-get-n-related-models-per-parent/, tested on hasMany and belongsToMany relationships
<?php
namespace App\Traits;
trait NPerGroup {
/**
* query scope nPerGroup
*
* @return void
*/
@Kursulla
Kursulla / Self signing certificate: Android and Retrofit
Last active November 13, 2018 16:58
Self signing certificate: Android and Retrofit
Enabling communication with API if server has Self-Signed Certificate
@yoggy
yoggy / gpu_hog.cpp
Created December 13, 2011 06:48
OpenCV cv::HOGDescriptor & cv::gpu::HOGDescriptor sample
#include <SDKDDKVer.h>
#include <Windows.h>
#pragma warning(disable:4819)
#pragma warning(disable:4996)
// for OpenCV2
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/gpu/gpu.hpp"
@dwmkerr
dwmkerr / setup-sublime3-for-angular2.md
Last active April 11, 2020 03:30
Quickly setup Sublime Text 3 for Angular 2

Quick Setup for Sublime Text 3 for Angular 2

Easy to remember, easy to forget.

Step 1: Download Sublime Text 3

Sublime Text 3 Download

Step 2: Create a bash shortcut

It's nice to be able to run subl in a terminal.

@joinAero
joinAero / FlymeUtils.java
Created February 17, 2016 13:04
Android - Helper for 3rd party roms: Flyme & MIUI.
package cc.cubone.turbo.core.rom;
import android.os.Build;
import android.view.Window;
import android.view.WindowManager;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
@katowulf
katowulf / firebase_copy.js
Last active July 29, 2022 15:58
Move or copy a Firebase path to a new location
function copyFbRecord(oldRef, newRef) {
oldRef.once('value', function(snap) {
newRef.set( snap.value(), function(error) {
if( error && typeof(console) !== 'undefined' && console.error ) { console.error(error); }
});
});
}
@samkirton
samkirton / gist:0242ba81d7ca00b475b9
Last active November 14, 2022 13:31
Fixed a bug where images added to the MediaStore are not inserted at the front of the gallery
package com.memtrip;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.graphics.Bitmap;
@radoyankov
radoyankov / Example.kt
Last active January 27, 2023 08:59
Easy Spannable on Kotlin
val spanned = spannable{ bold("some") + italic(" formatted") + color(Color.RED, " text") }
val nested = spannable{ bold(italic("nested ")) + url("www.google.com", "text") }
val noWrapping = bold("no ") + sub("wrapping ) + sup("also ") + "works"
text_view.text = spanned + nested + noWrapping
@michiexile
michiexile / gap.py
Created May 23, 2013 10:59
A Python implementation of the Gap Statistic from Tibshirani, Walther, Hastie to determine the inherent number of clusters in a dataset with k-means clustering.
# gap.py
# (c) 2013 Mikael Vejdemo-Johansson
# BSD License
#
# SciPy function to compute the gap statistic for evaluating k-means clustering.
# Gap statistic defined in
# Tibshirani, Walther, Hastie:
# Estimating the number of clusters in a data set via the gap statistic
# J. R. Statist. Soc. B (2001) 63, Part 2, pp 411-423
@buddax2
buddax2 / GoogleTranslate.workflow
Created March 25, 2018 22:37
Google Translate Automator Service
on run {input, parameters}
set output to "http://translate.google.com/translate_t?sl=auto&tl=uk&text=" & urldecode(input as string)
return output
end run
on urldecode(x)
set cmd to "'require \"cgi\"; puts CGI.escape(STDIN.read.chomp)'"
do shell script "echo " & quoted form of x & " | ruby -e " & cmd
end urldecode