Skip to content

Instantly share code, notes, and snippets.

View beydogan's full-sized avatar
🎯
Focusing

Mehmet Beydogan beydogan

🎯
Focusing
  • Hamburg, Germany
View GitHub Profile
DefaultTableModel tm = new DefaultTableModel();
Vector<String> columns = new Vector<String>();
columns.add("ID");
columns.add("From");
columns.add("To");
columns.add("Departure Time");
columns.add("Fare");
tm.setColumnIdentifiers(columns);
private void deleteRouteBtnActionPerformed(java.awt.event.ActionEvent evt) {
int row = routeListTable.getSelectedRow();
if(row != -1){
String routeId = routeListTable.getValueAt(row, 0).toString();
deleteRoute(Integer.parseInt(routeId));
loadRoutes();
}else{
JOptionPane.showMessageDialog(null, "You Must Select A Row To Delete");
}
public void deleteRoute(int routeId){
Route r = em.find(Route.class, routeId);
em.getTransaction().begin();
em.remove(r);
em.getTransaction().commit();
}
@beydogan
beydogan / JavaStringToDate
Created June 11, 2013 12:25
Java string to date
birthdate_s = "21/07/2013"
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date birthdate = new Date();
try {
birthdate = df.parse(birthdate_s);
} catch (ParseException ex) {
Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
}
@beydogan
beydogan / gist:5805406
Created June 18, 2013 13:35
order create method
# POST /orders
# POST /orders.json
def create
@order = current_user.orders.new(params[:order])
@order.add_line_items_from_cart(current_cart)
@order.payment.amount = @order.total_price
@order.payment.save
respond_to do |format|
if @order.save
Cart.destroy(session[:cart_id])
# POST /orders
# POST /orders.json
def create
@order = current_user.orders.new(params[:order])
@order.add_line_items_from_cart(current_cart)
@order.payment.amount = @order.total_price
@order.payment.save
respond_to do |format|
if @order.save
Cart.destroy(session[:cart_id])
username = 'beydogan'
user_repos = github.repos.list user: username
user_orgs = github.orgs.list user: username
user_repos.each do |repo|
name = repo.name
owner = repo.owner.login
commits = github.repos.commits.list owner, name, :author => username
@beydogan
beydogan / gist:6927650
Last active December 25, 2015 05:49
Github API - get all files of commits from user's repos
username = 'beydogan'
user_files = []
user_repos = github.repos.list user: username
user_orgs = github.orgs.list user: username
user_repos.each do |repo|
name = repo.name
owner = repo.owner.login
commits = github.repos.commits.list owner, name, :author => username
class CreateCommitPoints < ActiveRecord::Migration
def change
create_table :commit_points do |t|
t.integer :commit_id
t.integer :language_id
t.float :point
end
add_index :commit_points, [:commit_id, :language_id]
@beydogan
beydogan / insert_employee
Created November 29, 2013 00:44
CME4413 - Example Insert Query SQL
INSERT INTO EMPLOYEE VALUES
(2,
NAME_TYPE(TEMPORAL_VARCHAR('23.11.2003','09.09.2099','James Brown')),
ADDRESS_TYPE(TEMPORAL_VARCHAR('23.11.2003','09.09.9999','BUCA')),
'23.11.2003',
MANAGER_TYPE(TEMPORAL_VARCHAR('23.11.2003','09.09.9999','Mike White')),
DEPARTMENT_TYPE(TEMPORAL_VARCHAR('23.11.2003','09.09.9999','DEPT_ID05')),
SALARY_TYPE(TEMPORAL_NUMBER('23.11.2003','09.09.9999', 250000))
);