Skip to content

Instantly share code, notes, and snippets.

@droganov
droganov / Larry.gs
Last active September 7, 2023 20:45
Spreadsheets formula for calculating the tax base in Georgian Lari
function Larry(date, summ, currency) {
try {
var formattedDate = Utilities.formatDate(date, Session.getScriptTimeZone(), "yyyy-MM-dd");
var apiUrl = "https://nbg.gov.ge/gw/api/ct/monetarypolicy/currencies/en/json/?currencies=" + currency + "&date=" + formattedDate;
var response = UrlFetchApp.fetch(apiUrl);
var data = JSON.parse(response.getContentText());
var rate = data[0].currencies[0].rate;
var summ = parseFloat(summ.toString().replace(",", "."));
var result = summ * rate;
return result;
@droganov
droganov / page.tsx
Last active June 2, 2023 14:53
Conditional body class in Next.js 13 using app segments
'use client'
import { FunctionComponent } from 'react'
import { useSelectedLayoutSegments } from 'next/navigation'
import clsx from 'clsx'
import '../styles/globals.css'
type Props = {
children: JSX.Element
// Validator will pass a form to schema creator
export default form => ({
type: 'object',
properties: {
text: {
type: 'string',
messages: {
type: 'Should be a string',
required: 'Please enter a text',
},
@droganov
droganov / html5uploader.coffee
Created August 10, 2012 19:33 — forked from melito/html5uploader.coffee
Coffee Script html5 uploader
class HTML5Uploader
constructor:(obj, options) ->
@method = options['method'] ||= "POST"
@url = options['url'] ||= "/"
@params = options['params']
@obj = $(obj)
@files = []
@alerted = false
location / {
rewrite ^([^.]+)$ /index.cfm?vars=$1 last;
}
location ~ \.(cfm|cfc)$ {
proxy_pass http://127.0.0.1:8600;
proxy_redirect off;
proxy_intercept_errors on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
public function formapply(struct e){
try {
form.ip = e.t.getIP();
e.t.getBean("item").create(form, "stripHTML");
e.t.abort();
}
catch (any error) {
e.t.getService("log").exception(error);
e.t.setHttpCode(
Val(error.code) ? error.code : 500
var j = jQuery.noConflict();
j(function(){
j("#applyForm").submit(function(e){
e.preventDefault();
var form = j(this);
var success = j("#applyFormSuccess");
var submit = form.find("input:submit");
var error = form.find(".error").hide();
if(!submit.is(".busy")){
submit.addClass("busy");
<form id="applyForm" action="/form/apply" method="post">
<div class="row">
<label for="name">Ваше имя</label>
<input type="text" id="name" name="name" class="name" placeholder="Марк Цукерберг" />
<div class="clear"></div>
</div>
<div class="messageWrapper">
<div class="error hide"></div>
</div>
<div class="clear"></div>