Skip to content

Instantly share code, notes, and snippets.

$ python
Python 2.7.5 (default, Sep 12 2013, 21:33:34)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.getfqdn()
'Seans-MacBook-Pro.local'
>>> socket.getfqdn()
'187.1.168.192.in-addr.arpa'
>>> socket.getfqdn()
@cxxr
cxxr / pom.xml
Created April 15, 2014 23:11
Example Root POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>root-pom</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Root POM</name>
<url>http://git.example.com/rootpom.git</url>
@cxxr
cxxr / SearchES.java
Last active August 29, 2015 14:04
How to search Elasticsearch, with a good code contract
package me.seancassidy.search;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchPhaseExecutionException;
### Keybase proof
I hereby claim:
* I am cxxr on github.
* I am cxxr (https://keybase.io/cxxr) on keybase.
* I have a public key whose fingerprint is 341B 18FC C906 6E90 B01C FCC9 C89D 0488 91CF 72E7
To claim this, I am signing this object:
@cxxr
cxxr / gist:86c1b16acc52f1235d3a
Created February 17, 2016 22:01
PostgreSQL Inconsistent Lexicographic Sort
Run this SQL:
CREATE TEMPORARY TABLE SORTER ( name VARCHAR );
INSERT INTO SORTER (name) VALUES ('A B');
INSERT INTO SORTER (name) VALUES ('AB');
INSERT INTO SORTER (name) VALUES ('A C');
INSERT INTO SORTER (name) VALUES ('AC');
SELECT * FROM SORTER ORDER BY name;
SELECT * FROM SORTER ORDER BY name DESC;
@cxxr
cxxr / datesarecrazy.cs
Created July 14, 2017 19:34
C# date madness
static void Main()
{
var date1 = DateTime.Parse("2017-07-14T19:00:00.0000000-07:00");
var date2 = DateTime.UtcNow; // <- today at "19:09:56" UTC or "12:09:56" PDT
Console.WriteLine(date1 > date2); // False <-- what??
Console.WriteLine(date1.ToUniversalTime() > date2); // True
var nowStr = DateTime.UtcNow.ToString("o");
Console.WriteLine(nowStr); // "2017-07-14T19:09:56.0616752Z"
@cxxr
cxxr / weird_network_bug_macos
Last active September 1, 2017 17:46
Strange WiFi network bug on MacOS 10.12.6 on resume from sleep
Sometimes when I resume my macbook from sleep, the WiFi cycles in and out of working. It's fairly regular:
down for 51 seconds and up for 11 seconds most of the time. What could cause this?
➜ ~ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
64 bytes from 8.8.8.8: icmp_seq=3 ttl=59 time=4.976 ms
Here is some C code. Does this code have any vulnerabilities?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFERSIZE 200
#define TRUE 1
#define FALSE 0