Skip to content

Instantly share code, notes, and snippets.

View yusuke024's full-sized avatar

Yusuke Onishi yusuke024

  • Google
  • Tokyo, Japan
View GitHub Profile
@yusuke024
yusuke024 / bits.c
Created February 21, 2015 18:03
Bit manipulation in C
#include "bits.h"
const int NUM_BITS_IN_BYTE = 8;
int getbit(char c, int i) {
if (i >= NUM_BITS_IN_BYTE || i < 0) {
return -1;
}
return (c & (1 << i)) > 0;
}
package main
import (
"encoding/json"
"log"
"net/http"
)
type Comment struct {
Author string `json:"author"`
package main
import (
"flag"
"io"
"log"
"os"
"golang.org/x/net/websocket"
)
package main
import (
"bufio"
"container/list"
"flag"
"io"
"log"
"net/http"
"os"
//
// ColorListGenerator.m
//
@import AppKit;
NSColor *colorFromRGB(unsigned rgbValue) {
CGFloat r = (CGFloat)((rgbValue & 0xFF0000) >> 16);
CGFloat g = (CGFloat)((rgbValue & 0x00FF00) >> 8);
CGFloat b = (CGFloat)(rgbValue & 0x0000FF);
@import ObjectiveC;
@interface MyClass : NSObject
@end
@implementation MyClass
+ (void)methodA {
Method mb = class_getClassMethod([self class], @selector(methodB:));
var url = require('url');
var Crawler = require('crawler');
var moment = require('moment');
var _ = require('underscore');
var c = new Crawler({
maxConnections: 20
});
curl -s http://www.readmanga.today/naruto/700.2/all-pages | pup '.img-responsive-2 attr{src}' | xargs -n 1 curl -sO; convert * cartoon.pdf
#include <stdio.h>
#include <string.h>
void printBits(char *bits, size_t n) {
for (int i = 0; i < n; ++i) {
printf("%c", (bits[i/8] & (1 << (7 - i%8))) == 0 ? '0' : '1');
}
printf("\n");
}
// https://arena.topcoder.com/#/u/practiceCode/10882/7034/7850/1/265822
#include <map>
#include <vector>
using namespace std;
struct BestHotel {
int numberOfDisadvantageous(vector<int> price, vector<int> quality) {
map<int, int> bestHotels;