E.g. to copy every 4th byte from binary in_file to out_file:
xxd -p -c4 in_file | sed 's/\(.\{6\}\)\(..\)/\2/g' | xxd -p -r >out_file
xxd -p -c4 in_file | sed 's/\(.\{6\}\)\(..\)/\2/g' | xxd -p -r >out_file
exiftool -H -G:0:1 -Orientation IMG_6071.JPG
[EXIF:IFD0] 0x0112 Orientation : Horizontal (normal)
exiftool -H -G:0:1 -*Orientation IMG_6071.JPG
[EXIF:IFD0] 0x0112 Orientation : Horizontal (normal)
[MakerNotes:Canon] 0x0030 Camera Orientation : Rotate 270 CW
exiftool -H -G:0:1 -*Orientation# IMG_6071.JPG
[EXIF:IFD0] 0x0112 Orientation : 1
[MakerNotes:Canon] 0x0030 Camera Orientation : 2
exiftool -Orientation#=8 IMG_6071.JPG
exiftool -CameraOrientation#=0 IMG_6071.JPG
#!/bin/bash
orientation=$(exiftool -p '${Orientation#} ${CameraOrientation#}' "$1")
orient_array=($orientation)
if [ ${orient_array[0]} -eq 1 ] ; then
if [ ${orient_array[1]} -eq 1 ] ; then
echo "$1 - Camera Orientation - Rotate 90 CW - will be moved to EXIF Orientation";
# also reset Camera Orientation
exiftool -Orientation#=6 -CameraOrientation#=0 -overwrite_original $1
elif [ ${orient_array[1]} -eq 2 ] ; then
echo "$1 - Camera Orientation - Rotate 270 CW - will be moved to EXIF Orientation";
# also reset Camera Orientation
exiftool -Orientation#=8 -CameraOrientation#=0 -overwrite_original $1
fi
fi
convert -auto-orient -strip -resize x1080 file.jpg file_resized.jpg
vector<signed char> vc;
vc.push_back(1);
vc.push_back(255);
vc.push_back(1);
vc.push_back(1);
cout << find(vc.begin(), vc.end(), 255) - vc.begin() << endl;
}
private PointNode createKDTree(LatLngCommon[] points, int from, int to, int depth) {
if (from >= to) {
return null;
}
final int axis = depth % 2;
Arrays.sort(points, from, to, new Comparator<LatLngCommon>(){
@Override
public int compare(LatLngCommon ll1, LatLngCommon ll2) {
return (0==axis)
?(Double.compare(ll1.lat, ll2.lat))
:(Double.compare(ll1.lng, ll2.lng));
}
});
int med = (from + to) / 2;
PointNode res = new PointNode();
res.point = points[med];
res.left = createKDTree(points, from, med, depth+1);
res.right = createKDTree(points, med+1, to, depth+1);
return res;
}
private LatLngCommon findNearest(PointNode root, LatLngCommon point, int depth) {
Please take a look how distance is used. What we need to know is comparison result and not a distance value. Valuable is information if distance between one pair of points is larger/smaller than distance between other pair of points. Now, please note that when:
class MessageHandler
{
...
public:
virtual void doMessageHande(const Message &m) = 0;
MessageHandler(MessageHandlerRegistry ®)
{
reg.registry(*this); // now registry can call doMessageHandle() when message arrives
}
...
};
Solution 1 - base class (inheritance)
class A : private MessageHandler
{
...
void doMessageHandle(const Message &m); // won't get called for B objects
A(MessageHandlerRegistry ®)
: MessageHandler(reg) // registry A object as message handler
...
};
class B : public A, private MessageHandler
{
...
void doMessageHandle(const Message &m);
B(MessageHandlerRegistry ®)
: A(reg),
MessageHandler(reg) // registry B object as message handler
...
};
class A
{
...
class AMsgHander
: private MessageHandler {
A &_a;
};
AMsgHandler msg_handler;
public:
A(MessageHandlerRegistry ®) :
msg_handler(reg, *this)...
};
class MessageHandler
{
...
public:
typedef function1<void, const Message&> MessageCallback;
private:
MessageCallback _callback;public:
{
_callback(m);
}
void MessageHandler(MessageHandlerRegistry ®, const
MessageCallback &c) : _callback(c)
{
reg.registry(*this);
}
...
};
class A
{
private:
MessageHandler handler;
void doMessageHandle(const Message &m);
...
public:
A(MessageHandlerRegistry ®)
: handler(reg, std::bind1st(std::mem_fun(&A::
doMessageHandle), this))...
};