Skip to content

Instantly share code, notes, and snippets.

View unique-integers.cpp
vector<int> sumZero(int n) {
if (n == 0 || n == 1) return std::vector<int>(1, 0);;
std::vector<int> result;
for (int i = 1; i <= n/2; i++) {
result.push_back(i);
result.push_back(-i);
}
View logging.patch
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 533d82bcef63..857c08709d84 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -359,7 +359,7 @@ static void __gen6_gt_wait_for_fifo(struct intel_uncore *uncore)
if (wait_for_atomic((n = fifo_free_entries(uncore)) >
GT_FIFO_NUM_RESERVED_ENTRIES,
GT_FIFO_TIMEOUT_MS)) {
- drm_dbg_core(uncore->i915->drm, "GT_FIFO timeout, entries: %u\n", n)
+ drm_dbg_core(&uncore->i915->drm, "GT_FIFO timeout, entries: %u\n", n);
View myip.py
import sys
import logging
import os
from http.server import HTTPServer, BaseHTTPRequestHandler, SimpleHTTPRequestHandler
import socket
formatter = '[%(asctime)-15s] %(levelname)s [%(filename)s.%(funcName)s#L%(lineno)d] - %(message)s'
logging.basicConfig(level = logging.DEBUG, format = formatter)
View main.cpp
#include <iostream>
#include "tree.h"
int main(){
/* Create the tree as illustrated in thr
* program challenge description.
*/
Tree *tree = new Tree('a');
Node *temp_b = tree->create_child(tree->root, 'b');
@wambu-i
wambu-i / key-pair-client.py
Last active Dec 18, 2018
Database server.
View key-pair-client.py
import requests
class ServerRequest:
def __init__(self, host, port):
self.address = '{}:{}'.format(host, port)
def _get(self, key):
request = '{0}/get?key={1}'.format(self.address, key)
response = requests.get(request)
if response.status_code == 200:
@wambu-i
wambu-i / deque_using_doubly_linked.py
Last active Dec 10, 2018
Implementation of a Doubly Linked List in Python
View deque_using_doubly_linked.py
# Implementation of a dequeue using a doubly linked list
# Supports insertion and deletion of elements at both sides using FIFO
from doubly_linked import DoublyLinked
class LinkedDequeue(DoublyLinked):
'''A dequeue class that inherits from the DoublyLinked class.
It uses the inherited functions and attributes to perform dequeue functions.'''
def __init__(self):
super().__init__()
@wambu-i
wambu-i / crackle_pop.c
Last active Dec 12, 2018
CracklePop implementation in C.
View crackle_pop.c
#include <stdio.h>
#define MAX 100
void crackle_pop(){
for (int i = 1; i <= MAX; i++) {
if (i % 15 == 0) {
printf("CracklePop!\n");
}
else if (i % 3 == 0) {
You can’t perform that action at this time.