Skip to content

Instantly share code, notes, and snippets.

Stefan Fidanov fidanov

Block or report user

Report or block fidanov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fidanov
fidanov / cloudflare_worker.js
Created May 8, 2019
Resizing images on demand in Cloudflare Workers
View cloudflare_worker.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
@fidanov
fidanov / app.js
Created Aug 25, 2014
Basis express web app.js file.
View app.js
var express = require('express')
, app = express()
app.engine('jade', require('jade').__express)
app.set('view engine', 'jade')
app.use(express.static(__dirname + '/public'))
app.use(require('./controllers'))
app.listen(3000, function() {
View mxit.jade
mixin plan(name, price, limit, features, classes)
.PricingPlan(data-name=name, class=classes)
.PricingPlan-name= name
.PricingPlan-price= price
.PricingPlan-action Get this account
.PricingPlan-limit <b>#{limit}</b> responses / qurio pm
- for (var i = 0; i < 7; i++)
.PricingPlan-feature!= features[i]
extends /prelog/base
View Server.java
package com.example.package.name;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class Server {
public static class Result {
public int code;
View utilities.m
#import "Utilities.h"
@implementation Utilities
+ (CGSize)text:(NSString *)text sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size {
if(IOS_NEWER_OR_EQUAL_TO_7) {
CGRect frame = [text boundingRectWithSize: size
options: (NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading)
attributes: @{NSFontAttributeName: font}
context:nil];
@fidanov
fidanov / IO.java
Created Jul 19, 2012
Several very useful IO methods on Android.
View IO.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
import android.content.Context;
import android.net.Uri;
import android.os.Environment;
@fidanov
fidanov / Util.java
Created Jul 4, 2012
Android: DIP 2 PX programmatically. Works on any device with any density. Useful when settings width and height in code.
View Util.java
import android.content.Context;
import android.util.TypedValue;
public class Util {
public static int dp(Context context, int size) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
size,
context.getResources().getDisplayMetrics());
}
}
@fidanov
fidanov / Util.java
Created Jul 2, 2012
Transform any string to MD5 hash and then to HEX representation. Useful for file names.
View Util.java
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Util {
private static char[] hex = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
/**
* Transform any string to MD5 hash and then to HEX representation.
* Very useful for using strings as file names, like when the string
* is a url or another arbitrary string.
You can’t perform that action at this time.