This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Cache[K, V] { | |
| def put(key: K, value: V): Unit | |
| def get(key: K): Option[V] | |
| } | |
| class LruCache[K, V](capacity: Int) extends Cache[K, V] { | |
| /* | |
| A Least-Recently-Used cache is a cache with a fixed capacity: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Finder a = Finder { | |
| search :: Predicate a -> Maybe a | |
| -- you could imagine that a Finder | |
| -- has a set of As baked in, and that | |
| -- `search mypred` will just apply mypred | |
| -- to each element of the set until one | |
| -- passes | |
| } | |
| instance Functor Finder where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package co.hyp3r.data; | |
| import com.fasterxml.jackson.databind.ObjectMapper; | |
| import org.flowable.common.engine.impl.history.HistoryLevel; | |
| import org.flowable.common.engine.impl.interceptor.EngineConfigurationConstants; | |
| import org.flowable.engine.*; | |
| import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; | |
| import org.flowable.idm.api.IdmEngineConfigurationApi; | |
| import org.flowable.idm.api.IdmIdentityService; | |
| import org.flowable.job.service.impl.asyncexecutor.AsyncExecutor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FetchRequest req = new FetchRequestBuilder() | |
| .clientId(clientId) | |
| .addFetch(topic, partition, offset, fetchSize) | |
| .minBytes(1) | |
| .maxWait(250) | |
| .build(); | |
| FetchResponse resp = underlying.fetch(req); | |
| if(resp.hasError()) { | |
| int code = resp.errorCode(topic, partition); | |
| if (code == 9) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def passwordFrom[template String] String { | |
| map[template, passChar].scrambled | |
| } | |
| def passChar[c Rune] Rune { | |
| if c = { | |
| 'a': lowercase[rand[0, 26]] | |
| 'A': uppercase[rand[0, 26]] | |
| '0': digits[rand[0, 10]] | |
| '.': punctation[rand[0, 14]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def Part part(side Side, typ String, size Int) | |
| def Side { | |
| left | |
| right | |
| none | |
| } | |
| def symmetrize[parts Array[Part]] Array[String] { | |
| let symmetric Array[String] = newArray[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #from data:stack import * | |
| def Box box(st Int, hgt Int, wdt Int) | |
| def [st Int, hgt Int] .box [pos Int] Box { closed(st, hgt, pos - o:st) } | |
| def area[box Box] Int { box:hgt * box:wdt } | |
| def [a Box] > [b Box] Bool { area[a] > area[b] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func Daemonize() { | |
| go func() { | |
| fmt.Println("Daemonizing...") | |
| ch := make(chan os.Signal, 1) | |
| signal.Notify(ch, os.Signal(syscall.SIGHUP)) | |
| for _ = range ch { | |
| } | |
| }() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| records =\ | |
| (session.query(LaborItem) | |
| .join(ServiceUnit, ServiceUnit.id == LaborItem.punch_unit_id) | |
| .filter(LaborItem.date <= days[-1]) | |
| .filter(LaborItem.date >= days[0]) | |
| .filter(*unit_filters(LaborItem.punch_unit_id)) | |
| .filter(ServiceUnit.is_active_sql(days[-1]))# is this what we want for long date ranges? | |
| .options(sa.orm.joinedload('pay_type')) | |
| .options(sa.orm.joinedload('pay_type.versions')) | |
| .options(sa.orm.joinedload('punch_job')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pdb | |
| import sqlalchemy as sa | |
| from sqlalchemy import Column, Integer, String | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import sessionmaker | |
| Base = declarative_base() | |
| engine = sa.create_engine("sqlite:///:memory:", echo=True) |
NewerOlder