Skip to content

Instantly share code, notes, and snippets.

View bulkan's full-sized avatar
🇯🇵

Savun Bulkan Evcimen bulkan

🇯🇵
View GitHub Profile
@bulkan
bulkan / sequelize.md
Last active January 14, 2024 05:48
Using Sequelize migrations with an existing database

Install

I'm sure you know know how to install packages but here is the command for the sake of completeness

npm install sequelize async

The first migration

First initilize the migrations structure

@bulkan
bulkan / runQTPTest.py
Created September 18, 2009 06:37
Python script to run a QTP test
import win32com, win32com.client
qtp = win32com.client.Dispatch("QuickTest.Application")
# starts up QTP
qtp.Launch()
# make the QTP window visible
qtp.Visible = True
@bulkan
bulkan / js_fizzbuzz.js
Last active July 5, 2021 04:29
frontend fizzbuzz
// What does the following do ?
for(let i=0; i<=10; i++) {
fetch(`https://httpbin.org/get?someParam=${Date.now()}`)
.then(res => res.json())
.then(({origin}) => console.log(`${i} - ${origin}`));
}
@bulkan
bulkan / gist:4221633
Created December 6, 2012 03:48
How To Create a Django MultiWidget

What are MultiWidgets ?

A MultiWidget is a widget that contains more than one widget and bundles it into one. Sometimes you require two or more inputs from the user where the data is not mutually exclusive. For example the expiry date on a credit card or a phone number with the area code.

This blog post will show and explain how to create a MultiWidget for an expiry date that accepts a month and a year.

I heard you like Widgets so I put a Widget into your Widget so you can Widget

Creating a MultiWidget is similar to creating a custom Widget. Here is the code for an expiry date multiwidget that accepts two values the month and year that a credit card expires.

/**
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
* @version
* 3.0.83 (July 02 2010)
*
@bulkan
bulkan / user.js
Created January 7, 2015 22:39
Mocking Sequelize model function
var Promise = require('bluebird');
var sinon = require('sinon');
var User = require('./db/models').User;
describe('User model', function(){
var userFindStub;
var sandbox;
before(function(){
sandbox = sinon.sandbox.create();
@bulkan
bulkan / Dockerfile
Created August 19, 2018 23:32
Django sample Dockerfile
FROM python:3.6
ENV PYTHONUNBUFFERED 1
RUN groupadd -g 1001 -r django && useradd -m -u 1001 -r -g django django
WORKDIR /opt/project
USER root
ENV FILESYSTEM_ROOT /opt/project
COPY ./requirements.txt /opt/project/requirements.txt
RUN pip install pip --upgrade
LC_ALL=en_AU.UTF-8
LANG=en_AU.UTF-8
@bulkan
bulkan / heroku-anybar.js
Created May 9, 2018 07:51
show heroku ci status on anybar
const { exec } = require('child_process');
const anybar = require('anybar');
process.stdin.resume();
function exitHandler(err) {
if (err) {
console.error(err);
}
anybar('exclamation')
@bulkan
bulkan / jq.sh
Created March 6, 2018 23:45
example of munging JSON using jq and still getting valid JSON
#!/bin/bash
cat item.json | jq 'map( {
amount: .amount,
yieldFactor: .yieldFactor,
servingSize: .servingSize | { gramsEntered: .gramsEntered },
measures: .measures | map( {
amount: .amount,
gramsPerUnit: .gramsPerUnit
}),