Skip to content

Instantly share code, notes, and snippets.

View fart.py
# I've tried both of these:
try:
for part in parts:
dirs = [dir for dir in os.listdir(path_to_check) if not isfile(os.path.join(path_to_check, dir))]
if "thing" in dirs:
return path_to_check
del path_parts[-1]
else:
raise ValueError("thing not found")
@dhoss
dhoss / code-practice.md
Last active Nov 24, 2017
code practice
View code-practice.md
  • take a string, tokenize words, count number of unique words and have a method that can return top N distinct words: https://github.com/dhoss/gotoke
  • analyze csv log file of http requests. format will be request type,url,request status code, response size. group by url + request type, and aggregate the request size
  • create http crawler that will take number of parallel threads/requests, rate limit, and total number of requests to be executed as parameters and implement rate limiting, parallel requests and exit after maximum number of requests complete.
View dhoss.md
View gist:acf0d7e83e0e27e01402f0d6a5f469a9
sqlalchemy.engine.base.Engine: INFO: select version()
sqlalchemy.engine.base.Engine: INFO: {}
sqlalchemy.engine.base.Engine: INFO: select current_schema()
sqlalchemy.engine.base.Engine: INFO: {}
sqlalchemy.engine.base.Engine: INFO: SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
sqlalchemy.engine.base.Engine: INFO: {}
sqlalchemy.engine.base.Engine: INFO: SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
sqlalchemy.engine.base.Engine: INFO: {}
sqlalchemy.engine.base.Engine: INFO: show standard_conforming_strings
sqlalchemy.engine.base.Engine: INFO: {}
View BaseService.java
import org.jooq.Record;
import org.jooq.RecordMapper;
import com.lumos.db.tables.pojos.Images;
import org.jooq.Table;
import java.util.List;
import static com.lumos.db.Tables.IMAGES;
/**
@dhoss
dhoss / BaseService.java
Created May 26, 2016
recordmapper issues
View BaseService.java
package com.lumos.service;
import com.lumos.ConfigReader;
import com.lumos.util.Data;
import com.lumos.util.Page;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.RecordMapper;
import com.lumos.db.tables.pojos.Images;
import org.jooq.Table;
@dhoss
dhoss / BaseService.java
Created May 25, 2016
jooq base dao class issues
View BaseService.java
package com.lumos.service;
import com.lumos.ConfigReader;
import com.lumos.util.Data;
import com.lumos.util.Page;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.RecordMapper;
import com.lumos.db.tables.pojos.Images;
import org.jooq.Table;
@dhoss
dhoss / BaseService.java
Last active May 16, 2016
dao base class
View BaseService.java
public abstract class BaseService {
protected void create(GenericTablePojo tableObject) {
GenericRecord g = buildRecordObject(tableObject);
g.store();
}
protected void update(GenericTablePojo tableObject) {
GenericRecord g = buildGenericRecord(tableObject);
g.store();
View Main.java
import java.util.*;
class Main {
public static void main(String[] args) {
int[] nums1 = new int[] {
1, 2, 1
};
int[] nums2 = new int[] {
1, 0
};
View commit.html.erb
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Commit ID</th>
<th>Message</th>
<th>Author</th>
<th>Commit Timestamp</th>
</tr>
</thead>
You can’t perform that action at this time.