Skip to content

Instantly share code, notes, and snippets.

@burgalon
burgalon / AccountAuthenticator.java
Last active July 15, 2023 08:29
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
@burgalon
burgalon / sinatra_proxy
Last active September 25, 2020 15:34
Testing client side app (like BackboneJS) with Capybara, VCR, webmock, factory girl
Testing client side app (like BackboneJS) with Capybara, VCR, webmock, factory girl
@burgalon
burgalon / scroll.scss
Created July 20, 2020 08:49
Scrollable custom bar hiding Windows scrollbars and overlaying scrollbars on top
.scrollable-y-with-hide {
overflow-y: hidden;
&:hover {
overflow-y: auto;
// https://stackoverflow.com/a/54979559/375050
// only for WebKit so that scrollbars do not take space and cause content to overflow
overflow-y: overlay;
}
&::-webkit-scrollbar-thumb {
background: hsla(0%, 0%, 0%, 0.4);
@burgalon
burgalon / application_helper.rb
Created June 15, 2020 13:22
Rails Ellipsis helper with toggle
def ellipsis_text(s, limit=90)
if s&.length>limit
(s.slice(0..limit) +
'... ' +
content_tag(:a, 'More',
class: 'more semibold small',
href: '#',
onClick: "$(this.nextElementSibling).removeClass('hide'); $(this).addClass('hide'); return false;") +
content_tag(:span, s.slice(90..-1), class: 'hide')).html_safe
else
@burgalon
burgalon / DraggableModal.js
Created March 31, 2016 06:18
Draggable React Bootstrap modal
import { Modal } from 'react-bootstrap'
import ModalDialog from 'react-bootstrap/lib/ModalDialog'
class DraggableModalDialog extends React.Component {
render() {
return <Draggable handle=".modal-title"><ModalDialog {...this.props} /></Draggable>
}
}
// enforceForce=false causes recursion exception otherwise....
print('hello from iodide-toolbox');
@burgalon
burgalon / train.py
Created November 29, 2017 09:07
finetune imagenet
import argparse
import os
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torchvision.transforms as transforms
@burgalon
burgalon / bbox_utils.py
Created May 16, 2017 10:37
Utilities for bounding box
def transform_predicitions(window_prediction_bbox, xs, ys):
'''
Transform SSD bounding boxes in a sliding window, to absolute coordinates in the original image
'''
r= []
for label, score, xmin, ymin, xmax, ymax in window_prediction_bbox:
label = int(label)
xmin = math.ceil(xmin*box_width)+xs
xmax = math.ceil(xmax*box_width)+xs
ymin = math.floor(ymin*box_height)+ys
@burgalon
burgalon / gist:5579233
Last active March 9, 2017 00:55
Filter all extra logs "by Log Tax (regex)" in IntelliJ for Android adb logcat that are not relevant to debugging an app
^(?!.*(PullToRefresh|SherlockFragmentActivity|IInputConnectionWrapper|LightsService|CalendarSyncAdapter|Watson|ActionBarSherlock|alsa_ucm|mm-camera|qcom_sensors_hal|CellInfoLte|WirelessDisplayService|TELEPHONY_CALLBACK|StatusBar.*|memalloc|AlarmManager|SIGNAL_ICON|StateMachine|ThermalDaemon|overlay|AudioTrack|Trace|SyncManager|libEGL|GCMBaseIntentService|SubscribedFeeds|PackageManager|StorageNotification|libgps|DownloadManager|MountService|ActivityThread|SpannableStringBuilder|AlertService|Gmail|SurfaceFlinger|PhoneStatusBar|MtpService|PicasaUploader|chromium|BackupHelperDispatcher|BackupManagerService|PerformBackupTask|KeyInputQueue|LocationMasfClient|KeyguardViewMediator|WindowManager|InputDevice|jdwp|RecognizerEngine|VoiceDialerReceiver|PackageIntentReceiver|installd|UNA|VoldCmdListener|UnlockClock|sensor_stub|PowerManagerService|ExchangeService|EventLogService|Finsky|Zygote|BatteryService|SntpClient|ActivityManager|CalendarProvider2|SyncCampaign|AlarmScheduler|StatusBarPolicy|NetworkStatusReceiver|KeyChar
@burgalon
burgalon / App.js
Created April 28, 2016 10:25
use ToolbarAndroid with react-native-router-flux
export default class App extends React.Component {
render() {
return <Router>
<Scene key="root" navBar={Platform.OS=='ios' ? NavBar : NavBarAndroid}>
<Scene key="home" component={HomeScreen} ... />
</Scene>
</Router>
}
}