Skip to content

Instantly share code, notes, and snippets.

/bin/dd if=/dev/zero of=out.tmp bs=1M count=2048
@jampajeen
jampajeen / jira-behing-nginx-ssl
Created November 15, 2015 18:06 — forked from alertor/jira-behing-nginx-ssl
Atlassian JIRA behind nginx + SSL
# force HTTP to HTTPS - /etc/nginx/conf.d/nonssl.conf
server {
listen 80;
server_name jira.example.com;
access_log off;
return 301 https://$server_name$request_uri;
}
# /etc/nginx/conf.d/jira.conf
server {
@jampajeen
jampajeen / InternalAuthTokenGenerator.java
Created February 20, 2016 04:00
Generate oauth token
/*
* Copyright 2016 Thitipong Jampajeen <jampajeen@gmail.com>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jampajeen
jampajeen / console-progress.c
Created October 27, 2016 21:10
console progress bar
#include <stdio.h>
#include <cstdlib>
#define PROGRESS_BAR_STR "================================="
#define PROGRESS_BAR_WIDTH sizeof(PROGRESS_BAR_STR)
void print_progress_bar(size_t completed, size_t total) {
const char operation[] = "Downloaded";
const char prefix[] = " kMGT";
@jampajeen
jampajeen / gist:9ce8876ae829efd69aaa
Last active October 27, 2016 21:14
Hibernate non-entity mapping
Query query = session.createSQLQuery(sql);
query.setResultTransformer( Transformers.aliasToBean( Test.class) );
List<Test> result = query.list();
@jampajeen
jampajeen / console-app-args.c
Created November 2, 2016 17:51
console app option in C
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define OPT1 "Operation1"
#define OPT2 "Operation2"
struct global_args_t {
const char *program_name;
@jampajeen
jampajeen / cron-desc.txt
Created November 16, 2016 12:12
cron description
+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 6) (Sunday=0 or 7)
| | | | |
* * * * * command to be executed
@jampajeen
jampajeen / gist:442fbe2902a98fdb44582985f52c56f5
Created January 26, 2017 20:56
SSH to System VM from the Host on which the VM is running - cloudstack
Format: ssh -i <path-to-private-key> <link-local-ip> -p 3922
Example: root@faith:~# ssh -i /root/.ssh/id_rsa.cloud 169.254.3.93 -p 3922
<select id="country" name="country" class="full-width" selected="" data-init-plugin="select2">
<option value="AF">Afghanistan</option>
<option value="AX">Åland Islands</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
@jampajeen
jampajeen / AND_OR_NOT
Created August 29, 2017 13:34 — forked from oliverdoetsch/AND_OR_NOT
Blogger: Globally conditional data tags for all page types
#AND
<b:if cond='data:blog.pageType == "index"'>
<b:if cond='data:blog.searchQuery'>
<!--search_page AND index_page-->
</b:if>
</b:if>
#OR