This file contains 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
var LRUCache = require('mnemonist/lru-cache'); | |
var getJobPostCache = new LRUCache(1000); | |
export const getJobPostJson = async (jobId: string) => { | |
const job = getJobPostCache.get(jobId) | |
if (job !== undefined) { | |
return ({ | |
job, | |
isJobBelongsToThisUser: true | |
}) |
This file contains 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
zplug "avivl/gcloud-project", use:init.sh |
This file contains 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
gmaps = googlemaps.Client(key=key) | |
reverse_geocode_result = gmaps.reverse_geocode( | |
(location['latitude'], location['longitude'])) | |
now = datetime.datetime.now() | |
directions_result = gmaps.directions( | |
reverse_geocode_result[0]['formatted_address'], | |
home[0]['address'], | |
mode="driving", | |
departure_time=now) | |
fulfillment_text = Name + " will be home in %s" % \ |
This file contains 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
api = PyiCloudService(user_mail, password) | |
location = api.iphone.location() | |
if location['isOld']: | |
fulfillment_text = "Can't get an accurate location for %s" % Name | |
body = '{"fulfillmentText":"%s"}' % fulfillment_text | |
return body | |
This file contains 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
// Payload is the event's actual data inserted into data stores. | |
type Payload map[string]interface{} | |
// Type is an Event's metadata. | |
type Type struct { | |
EventVersionField string `json:"event_version" valid:"notempty,required"` | |
EventNameField string `json:"event_name" valid:"notempty,required"` | |
} | |
type Event struct { |
This file contains 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 (c *Collector) Collect(ctx *fasthttp.RequestCtx) { | |
defer func(begin time.Time) { | |
responseTime := float64(time.Since(begin).Nanoseconds() / 1000) | |
occtx, _ := tag.New(context.Background(), tag.Insert(codeKey, strconv.Itoa(ctx.Response.StatusCode())), ) | |
stats.Record(occtx, requestCounter.M(1)) | |
stats.Record(occtx, requestlatency.M(responseTime)) | |
}(time.Now()) | |
/*do some stuff */ | |
} |
This file contains 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 ( | |
"go.opencensus.io/stats" | |
"go.opencensus.io/tag" | |
"go.opencensus.io/stats/view" | |
) | |
var ( | |
requestCounter *stats.Float64Measure | |
requestlatency *stats.Float64Measure | |
codeKey tag.Key |
This file contains 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 ( | |
"go.opencensus.io/exporter/prometheus" | |
"go.opencensus.io/exporter/stackdriver" | |
"go.opencensus.io/stats/view" | |
) | |
Exporter, err := prometheus.NewExporter(prometheus.Options{}) | |
if err != nil { | |
logger.Error("Error creating prometheus exporter ", zap.Error(err)) | |
} |
This file contains 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 change_status(self, to_status, tagkey, tagvalue): | |
""" | |
Stop/start instance based on tags | |
Args: | |
to_status: 0 stop 1 start | |
tagkey: tag key | |
tagvalue: tag value | |
Returns: |
This file contains 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 policy_checker(name): | |
""" | |
Check if there is a need to take an action for a policy. | |
Args: | |
name: policy name | |
Returns: | |
""" | |
policy = PolicyModel.query(PolicyModel.Name == name).get() |
NewerOlder