Skip to content

Instantly share code, notes, and snippets.

View cemremengu's full-sized avatar
😵

Cemre Mengu cemremengu

😵
View GitHub Profile
@cemremengu
cemremengu / paginator.go
Created October 12, 2022 07:41
paginator.go
package paginator
import (
"context"
"database/sql"
"errors"
"github.com/uptrace/bun"
"math"
)
@cemremengu
cemremengu / snowflake-id.sql
Created April 29, 2022 11:14 — forked from beginor/snowflake-id.sql
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
// Downloading a static resource, already saved to disk
@GetMapping(value = "/")
public ResponseEntity download() throws IOException {
var file = new File("/path/to/file");
var header = new HttpHeaders();
header.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + file.getName()); // you can use any name you want here
header.add("Cache-Control", "no-cache, no-store, must-revalidate");
header.add("Pragma", "no-cache");
header.add("Expires", "0");
SELECT to_date('01/01/1900','DD/MM/YYYY') + NUMBER_OF_DAYS - 2 FROM DUAL
select * from INF_LR_POOL WHERE REGEXP_LIKE(POOL_ONAIR_DATE, '\d{5}')
UPDATE INF_UR_POOL SET POOL_ONAIR_DATE = to_char(to_date('01/01/1900','DD/MM/YYYY') + POOL_ONAIR_DATE - 2, 'YYYY-MM-DD')WHERE REGEXP_LIKE(POOL_ONAIR_DATE, '\d{5}')
@cemremengu
cemremengu / create-group-modal.js
Last active April 3, 2019 08:50
react-modal-sample
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Modal, Input, Form } from 'antd';
const FormItem = Form.Item;
const { TextArea } = Input;
const formItemLayout = {
wrapperCol: {
span: 25
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters\ /v AllowEncryptionOracle /t REG_DWORD /d 2
import Papa from 'papaparse';
import { saveAs } from 'file-saver/FileSaver';
export default async ({ payload, filename }) => {
saveAs(
new Blob([Papa.unparse(payload)], { type: 'text/plain;charset=utf-8' }),
`${filename}.csv`
);
};
// true-type-of.js
export const trueTypeOf = input => Object.prototype.toString.call(input)
.replace(/(\[object |\])/ig, '')
.toLowerCase();
@cemremengu
cemremengu / bulk_processor_example1.go
Created February 9, 2018 19:28 — forked from olivere/bulk_processor_example1.go
Example #1 of bulk processor usage
// This is an example of using elastic's BulkProcessor with Elasticsearch.
//
// See https://github.com/olivere/elastic and
// and https://github.com/olivere/elastic/wiki/BulkProcessor
// for more details.
/*
* This example illustrates a simple process that performs bulk processing
* with Elasticsearch using the BulkProcessor in elastic.
*
@cemremengu
cemremengu / OracleDynamicParameters.cs
Created April 28, 2017 00:10 — forked from vijayganeshpk/OracleDynamicParameters.cs
OracleDynamicParameters class for Dapper
using Dapper;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
public class OracleDynamicParameters : Dapper.SqlMapper.IDynamicParameters {
private static Dictionary<SqlMapper.Identity, Action<IDbCommand, object>> paramReaderCache = new Dictionary<SqlMapper.Identity, Action<IDbCommand, object>>( );