Skip to content

Instantly share code, notes, and snippets.

code problem 2: -1
class GenericEngine {public String engType = "GE-001";}
class CombustionEngine extends GenericEngine {public String engType = "CE-002";}
class JetEngine extends CombustionEngine {public String engType = "JE-003";}
public class Car {
public void setEngine(Object o) {System.out.println("I have unknown engine");}
public void setEngine(GenericEngine ge) {System.out.printf("I have generic engine: %s", ge.engType);}
public void setEngine(CombustionEngine ce) {System.out.printf("I have combustion engine: %s", ce.engType);}
public static void main(String[] args) {JetEngine e = new JetEngine(); new Car().setEngine(e);}
import pyautogui as p
from time import sleep
def program():
a = p.pixel(747,281)[0]
b = p.pixel(982,185)[0]
p.hotkey('altleft','tab')
sleep(1)
p.press('space')
service = build('calendar', 'v3', credentials=creds)
try:
calendar_results = service.calendarList().list(
maxResults=100).execute()
calendars = calendar_results.get('items', [])
for calendar in calendars:
calendar_with_id.append((calendar['id'], calendar['summary']))
print(calendar['id'])
except Exception as exception:
print(exception)
@sergeevyi
sergeevyi / nginx.conf
Created July 20, 2018 05:30 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
{"data": {
"id": 8835,
"introduction": "BLOG",
"title": "Home",
"permalink": "",
"pageLayoutType": "BLOG_POST",
"blogPosts":[
{
"previewImageUrl":"",
"layout":[
@sergeevyi
sergeevyi / ionic.md
Created November 1, 2016 07:49
Ionic commands

ionic platform rm android ionic platform add android ionic platform list

@sergeevyi
sergeevyi / isblank.js
Created October 21, 2016 07:55
isBlank()
function isBlank(value) {
return _.isEmpty(value) && !_.isNumber(value) || Number.isNaN(value);
}
function test() {
console.log( "null: "+isBlank(null) ); // => true
console.log( "undefined: "+isBlank(undefined) ); // => true
console.log( "1: "+isBlank(1) ); // => true
console.log( "0: "+isBlank(0) );
console.log( "blank string: "+isBlank("") );
@sergeevyi
sergeevyi / UTC_to_localtime.js
Created October 21, 2016 07:50
UTC to Local Date Time Filter
(function () {
'use strict';
angular
.module('app')
.filter('utcToLocal', Filter);
function Filter($filter) {
return function (utcDateString, format) {
// return if input date is null or undefined
@sergeevyi
sergeevyi / gist:c0298a7ca0c4598a45db36592c04b25f
Created October 21, 2016 07:47
Auto-logout if any unauthorised web api request is made
app.config(['$provide', '$httpProvider', function ($provide, $httpProvider) {
$provide.factory('unauthorisedInterceptor', ['$q', function ($q) {
return {
'responseError': function (rejection) {
if (rejection.status === 401) {
window.location.href = '/#/login';
}
return $q.reject(rejection);